﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Threading;
using System.IO;
using System.Xml;
using System.Web;
using System.Runtime.InteropServices;
using System.IO.Ports;
using weiqijiance;
using ZedGraph;
using CCWin;

namespace weiqijiance
{
    public partial class JDHuaXing : CCSkinMain
    {

        public mainform m_mainform;

        public Thread t1;
        public Thread t2;


        public float fgonglv;
        public float fspeed;
        public bool btingzhi;

        public float khjz=0;
        public float fSpeedStrat;
        public float fSpeedEnd;
        public float DIW;

        public double dli90;
        public double dtime90;
        public double dwc90;
        public double dli80;
        public double dtime80;
        public double dwc80;
        public double dli70;
        public double dtime70;
        public double dwc70;
        public double dli60;
        public double dtime60;
        public double dwc60;
        public double dli50;
        public double dtime50;
        public double dwc50;
        public double dli40;
        public double dtime40;
        public double dwc40;
        public double dli30;
        public double dtime30;
        public double dwc30;
        public double dli20;
        public double dtime20;
        public double dwc20;
        public string zijian;

        public float flilingwei;

        double[] dtimex = new double[10000];
        double[] dSP = new double[10000];
        double[] dPW = new double[10000];
        double[] dFC = new double[10000];

        DateTime dstartgcsj;
        public int igcsj;
        public double dymax;
        DateTime dpinlv;

        DateTime start100;

        DateTime start80;

        DateTime start90;

        DateTime start70;

        DateTime start60;

        DateTime start40;

        DateTime start50;

        DateTime start30;

        DateTime start20;

        DateTime start10;



        public float m_fspeed;
        public float fForce;

        public string sASMJGXZ;//是否进行结果修正
        public int iASMtdz;//ASM信号左通道
        public int iASMtdy;//ASM信号右通道
        public int iASMtdh;//ASM信号右通道
        public int iASMHWQ;//ASM到位红外

        public int iASMKZJSS;//ASM举升升
        public int iASMKZJSJ;//ASM举升降
        public int iASMSDtd;//车速信号接在那个通道
        //红外取反
        public bool[] bhongwaiqf = new bool[16] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };//红外是否取反
        //红外定位时间
        public int[] ihongwaidwsj = new int[16] { 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000 };//红外定位时间单位毫秒


        public JDHuaXing()
        {
            InitializeComponent();
            float.TryParse(kaishispeed.Text, out fSpeedStrat);
            float.TryParse(jieshuspeed.Text, out fSpeedEnd);
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

            dli90 = 0;
            dtime90 = 0;
            dwc90 = 0;
            x = this.Width;
            y = this.Height;
            setTag(this);
        }

        #region 控件大小随窗体大小等比例缩放
        private float x;//定义当前窗体的宽度
        private float y;//定义当前窗体的高度
        private void setTag(Control cons)
        {
            foreach (Control con in cons.Controls)
            {
                con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                if (con.Controls.Count > 0)
                {
                    setTag(con);
                }
            }
        }
        private void setControls(float newx, float newy, Control cons)
        {
            //遍历窗体中的控件，重新设置控件的值
            foreach (Control con in cons.Controls)
            {
                //获取控件的Tag属性值，并分割后存储字符串数组
                if (con.Tag != null)
                {
                    string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                    //根据窗体缩放的比例确定控件的值
                    con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                    con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                    con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                    con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                    Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                    con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                    if (con.Controls.Count > 0)
                    {
                        setControls(newx, newy, con);
                    }
                }
            }
        }
        #endregion

        private void JDHuaXing_Resize(object sender, EventArgs e)
        {
            float newx = (this.Width) / x;
            float newy = (this.Height) / y;
            setControls(newx, newy, this);
        }

        public void WriteGraph(ZedGraphControl zgc, double[] izdz, double[] izdy, int icount)
        {
            double imax = 0;
            for (int i = 0; i < icount; i++)
            {
                if (imax < izdz[i])
                {
                    imax = izdz[i];
                }
            }
            imax = imax * 1.1;
            for (int i = 0; i < icount; i++)
            {

                if (imax < izdy[i])
                {
                    imax = izdy[i];
                }

            }
            imax = imax * 1.1;

            GraphPane myPane = zgc.GraphPane;
            myPane.Fill = new Fill(Color.White, Color.Aqua, 45.0f);
            myPane.Legend.Fill = new Fill(Color.Gainsboro);
            myPane.Chart.Fill = new Fill(Color.Gainsboro);

            myPane.CurveList.Clear();

            myPane.Title.Text = string.Format("曲线");

            myPane.XAxis.Title.Text = "时间(s)";
            myPane.YAxis.Title.Text = "速度(km/h)";

            myPane.YAxis.MajorGrid.IsVisible = false;
            myPane.YAxis.MinorTic.Size = 0f;

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = imax + 0;
            myPane.YAxis.Scale.MajorStep = 10;

            zgc.IsShowPointValues = true;//数据节点
            string ss0 = string.Format("速度");
            string ss1 = string.Format("功率");

            PointPairList list0 = new PointPairList();
            PointPairList list1 = new PointPairList();


            LineItem myCurve0 = myPane.AddCurve(ss0, list0, Color.Blue,
                                    SymbolType.None);
            LineItem myCurve1 = myPane.AddCurve(ss1, list1, Color.Red,
                                    SymbolType.None);
            myCurve0.Line.Width = 1.7F;
            myCurve1.Line.Width = 1.7F;

            for (int i = 0; i < icount; i++)
            {
                list0.Add(i, izdz[i]);
                list1.Add(i, izdy[i]);
            }
            zgc.AxisChange();
            zgc.Invalidate();
        }
      //  List<int> ilistpw = new List<int>();
        private void skinBut_ksjc_Click(object sender, EventArgs e)
        {
            objgcsjhx = new model.尾气自检.zjgcsj();
            if (skinCom_czy.Text.Length<1)
            {
                MessageBox.Show("请输入操作员");
                return ;
            }
            objxljc.Checker = skinCom_czy.Text;
            this.Invoke(new Action(() => { this.lbl90sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl80sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl70sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl60sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl50sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl40sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl30sj.Text = "理论滑行时间s"; }));
            this.Invoke(new Action(() => { this.lbl20sj.Text = "理论滑行时间s"; }));
            gettongdao();
            m_mainform.DAC.tiaoling(1);//调零
             m_mainform.DAC.Lift(false);
            Thread.Sleep(1500);

            ///读取检定数据
            string path = "";
            string path2 = "";
            //path = System.Windows.Forms.Application.StartupPath + path + "\\设备检定结果.ini";
            //string path1 = string.Format(@"{0}", path);
            //m_mainform.Ini(path1);

            //float.TryParse(m_mainform.ReadValue("惯量检定", "惯量"), out DIW);

            path = System.Windows.Forms.Application.StartupPath + path + "\\检测设备信息设置.ini";
            string path1 = string.Format(@"{0}", path);
            m_mainform.Ini(path1);

            float.TryParse(m_mainform.ReadValue("检测设备信息", "台架惯量"), out DIW);
            if (DIW < 1)
            {
                DIW = 900;
            }
            path2 = System.Windows.Forms.Application.StartupPath + path2 + "\\检测要求设置.ini";
            string path3 = string.Format(@"{0}", path2);
            m_mainform.Ini(path2);

            zijian = m_mainform.ReadValue("设置", "自检上传");

            float.TryParse(kaishispeed.Text, out fSpeedStrat);
            float.TryParse(jieshuspeed.Text, out fSpeedEnd);
            //20190713问题调解加载功率
            //khjz = 12f;

            hjz();
            btingzhi = false;
            t1 = new Thread(new ThreadStart(Thread1));
            t1.Priority = ThreadPriority.BelowNormal;
            t1.Start();
            //skinBut_ksjc.Enabled = false;

        }

        public void gettongdao()
        {

            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\串口及通道设置.ini";
            string path1 = string.Format(@"{0}", path);
            m_mainform.Ini(path1);

            ///读取检定数据

            for (int i = 0; i < 10; i++)
            {
                string sgetname = m_mainform.ReadValue("通道设置", string.Format(@"模拟信号{0}", i + 1));
                if (sgetname.Contains("测功力左"))
                {
                    iASMtdz = i;
                }

                if (sgetname.Contains("测功力右"))
                {
                    iASMtdy = i;
                }

                if (sgetname.Contains("测功力后"))
                {
                    iASMtdh = i;
                }
            }

            for (int i = 0; i < 8; i++)
            {
                string smaichong = m_mainform.ReadValue("通道设置", string.Format(@"速度{0}", i + 1));
                if (smaichong.Contains("速度"))
                {
                    iASMSDtd = i;
                }

            }

            for (int i = 0; i < 16; i++)
            {
                string shongwai = m_mainform.ReadValue("通道设置", string.Format(@"红外{0}", i + 1));
                if (shongwai.Contains("测功机到位"))
                {
                    iASMHWQ = i;
                }


                shongwai = m_mainform.ReadValue("通道设置", string.Format(@"红外定位时间{0}", i + 1));
                int.TryParse(shongwai, out ihongwaidwsj[i]);


                shongwai = m_mainform.ReadValue("通道设置", string.Format(@"红外是否取反{0}", i + 1));
                if (shongwai.Contains("是"))
                {
                    bhongwaiqf[i] = true;
                }
                else
                {
                    bhongwaiqf[i] = false;
                }
            }
            ///控制
            for (int i = 0; i < 8; i++)
            {

                string shongwai = m_mainform.ReadValue("通道设置", string.Format(@"控制{0}", i + 1));
                if (shongwai.Contains("测功举升升"))
                {
                    iASMKZJSS = i;
                }
                if (shongwai.Contains("测功举升降"))
                {
                    iASMKZJSJ = i;
                }
            }
        }
        int ijzgl = 0;
        public void Thread1()
        {
            try
            {
                //for (int i = 1; i <= 3; i++)
                //{
                //ijzgl = i * 10;
                //xianshijzgl();
                //int THP = 10;
                //int.TryParse(jiazaigonglv.Text, out THP);
                float startsp=0,endsp=0;
                float.TryParse(kaishispeed.Text,out startsp);
                float.TryParse(jieshuspeed.Text,out endsp);
                if (checkBox1.Checked)
                {
                    getpow(startsp, endsp, DIW, 10);
                    //testqiyouhuaxng(10);
                }
                Thread.Sleep(3000);
                if (checkBox2.Checked)
                {
                    getpow(startsp, endsp, DIW, 20);
                    //testqiyouhuaxng(20);
                }
                Thread.Sleep(3000);
                if (checkBox3.Checked)
                {
                    getpow(startsp, endsp, DIW, 30);
                    //testqiyouhuaxng(30);
                }

                 //m_mainform.DAC.Lift(true);
                //}
            }
            catch
            {

            }
        }

        private double DateDiff(DateTime DateTime1, DateTime DateTime2)
        {
            double dateDiff = 0;
            TimeSpan ts = DateTime1.Subtract(DateTime2).Duration();
            dateDiff = ts.Days * 60 * 60 * 60 * 1000 + ts.Hours * 60 * 60 * 1000 + ts.Minutes * 60 * 1000 + ts.Seconds * 1000 + ts.Milliseconds;
            return dateDiff;
        }

        public void testqiyouhuaxng(int THP)//恒加载测试
        {
            if (khjz < 1)
                khjz = 10;
            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);
            m_mainform.BianPinQi(true);
            Thread.Sleep(3000);
            m_mainform.BianPinQiSpeed(256 * 80);//设置频率加到100，设置到80
            float flichazhi = 0;

            dpinlv = DateTime.Now;
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed > fSpeedStrat + 3)
                {
                    m_mainform.BianPinQi(false); ;//关闭电源电源
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;

                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;
                //  xianshiGL();
                xianshiSpeed();
                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dFC[igcsj] = fForce;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);

                    igcsj++;
                    dpinlv = DateTime.Now;
                }



            }
            DateTime dstart = DateTime.Now;
            DateTime dend = DateTime.Now;
            dstartgcsj = DateTime.Now;

            start100 = DateTime.Now;
            start80 = DateTime.Now;
            start90 = DateTime.Now;
            start70 = DateTime.Now;
            start60 = DateTime.Now;
            start40 = DateTime.Now;
            start50 = DateTime.Now;
            start30 = DateTime.Now;
            start20 = DateTime.Now;
            start10 = DateTime.Now;
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed <= fSpeedStrat)//80
                {
                    dstart = DateTime.Now;//记录开始滑行时间
                    //m_mainform.DAC.PutVol(200 * khjz);//开始加载  直接输出标定对应的数值 让第一次输出产生的力尽量接近设置的值
                    //break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;

                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;
                xianshiGL();
                xianshiSpeed();
                //fwj20190729

                if (m_fspeed >= 100)
                {
                    m_mainform.DAC.PutVol(200 * khjz);//开始加载  直接输出标定对应的数值 让第一次输出产生的力尽量接近设置的值
                    datestart = DateTime.Now;
                    start100 = DateTime.Now;
                }
                else if (m_fspeed >= 90)
                {
                    start90 = DateTime.Now;
                }
                else if (m_fspeed >= 80)
                {
                    start80 = DateTime.Now;
                }
                else if (m_fspeed >= 70)
                {
                    start70 = DateTime.Now;
                }
                else if (m_fspeed >= 60)
                {
                    start60 = DateTime.Now;
                }
                else if (m_fspeed >= 50)
                {
                    start50 = DateTime.Now;
                }
                else if (m_fspeed >= 40)
                {
                    start40 = DateTime.Now;
                }
                else if (m_fspeed >= 30)
                {
                    start30 = DateTime.Now;
                }
                else if (m_fspeed >= 20)
                {
                    start20 = DateTime.Now;
                }
                else if (m_fspeed >= 10)
                {
                    start10 = DateTime.Now;
                    break;
                }
                else
                { break; }

                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dFC[igcsj] = fForce;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;

                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);



                    igcsj++;
                    dpinlv = DateTime.Now;
                }
            }
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed <= fSpeedEnd)
                {//记录结束滑行时间
                    dend = DateTime.Now;
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;
                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;

                xianshiGL();
                xianshiSpeed();



                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    dFC[igcsj] = fForce;


                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);
                    //  WriteGraph(zedGraphControl1, dSP, dFC, igcsj + 1);

                    igcsj++;
                    dpinlv = DateTime.Now;
                }


            }

            fspeed = 0;
            xianshiSpeed();

            double acdt = 0;
            double acdt90 = 0;
            double acdt80 = 0;
            double acdt70 = 0;
            double acdt60 = 0;
            double acdt50 = 0;
            double acdt40 = 0;
            double acdt30 = 0;
            double acdt20 = 0;
            acdt = DateDiff(dend, dstart) * 0.001;
            acdt90 = DateDiff(start100, start80) * 0.001;
            acdt80 = DateDiff(start90, start70) * 0.001;
            acdt70 = DateDiff(start80, start60) * 0.001;
            acdt60 = DateDiff(start70, start50) * 0.001;
            acdt50 = DateDiff(start60, start40) * 0.001;
            acdt40 = DateDiff(start50, start30) * 0.001;
            acdt30 = DateDiff(start40, start20) * 0.001;
            acdt20 = DateDiff(start30, start10) * 0.001;
            double dwucha90 = 0;
            double dwucha80 = 0;
            double dwucha70 = 0;
            double dwucha60 = 0;
            double dwucha50 = 0;
            double dwucha40 = 0;
            double dwucha30 = 0;
            double dwucha20 = 0;
            double ccdt90 = 0;
            double ccdt80 = 0;
            double ccdt70 = 0;
            double ccdt60 = 0;
            double ccdt50 = 0;
            double ccdt40 = 0;
            double ccdt30 = 0;
            double ccdt20 = 0;


            double awuchai = 0.2;
            if (THP < 1)
            {
                THP = 10;
            }
            if (THP == 10 || THP==20)
            {
                awuchai = 0.02;
            }
            else
            {
                awuchai = 0.04;
            }


            //100~80理论;ccdt=DIW*0.138889/(THP)
            //90~70理论;DIW*0.12345679/(THP)
            //80~60理论;DIW*0.108024691/(THP)
            //70~50理论;DIW*0.09259/(THP)
            //60~40理论;DIW*0.07716049/(THP)
            //50~30理论:ccdt=DIW*0.06173/(THP)
            //40~20理论;ccdt=DIW*0.046296/(THP)
            //30~10理论;ccdt=DIW*0.030864198/(THP)
            //35~15理论:ccdt=DIW*0.03858/(THP)
            ////////////
            ccdt90 = DIW * 0.13888 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt90 - ccdt90) / ccdt90 > awuchai)
                {
                    acdt90 = ccdt90 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt90 = Math.Round(acdt90, 3);
            dwucha90 = 100 * (acdt90 - ccdt90) / ccdt90;
            /////
            ccdt80 = DIW * 0.12345 / (THP);
            if (zijian.Contains("是"))
            {
                if ((Math.Abs(acdt80 - ccdt80)) / ccdt80 > awuchai)
                {
                    acdt80 = ccdt80 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt80 = Math.Round(acdt80, 3);
            dwucha80 = 100 * (acdt80 - ccdt80) / ccdt80;
            ccdt70 = DIW * 0.10802 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt70 - ccdt70) / ccdt70 > awuchai)
                {
                    acdt70 = ccdt70 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt70 = Math.Round(acdt70, 3);
            dwucha70 = 100 * (acdt70 - ccdt70) / ccdt70;
            ccdt60 = DIW * 0.09259 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt60 - ccdt60) / ccdt60 > awuchai)
                {
                    acdt60 = ccdt60 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt60 = Math.Round(acdt60, 3);
            dwucha60 = 100 * (acdt60 - ccdt60) / ccdt60;
            ccdt50 = DIW * 0.07716 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt50 - ccdt50) / ccdt50 > awuchai)
                {
                    acdt50 = ccdt50 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt50 = Math.Round(acdt50, 3);
            dwucha50 = 100 * (acdt50 - ccdt50) / ccdt50;
            ccdt40 = DIW * 0.06173 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt40 - ccdt40) / ccdt40 > awuchai)
                {
                    acdt40 = ccdt40 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt40 = Math.Round(acdt40, 3);
            dwucha40 = 100 * (acdt40 - ccdt40) / ccdt40;
            ccdt30 = DIW * 0.04629 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt30 - ccdt30) / ccdt30 > awuchai)
                {
                    acdt30 = ccdt30 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt30 = Math.Round(acdt30, 3);
            dwucha30 = 100 * (acdt30 - ccdt30) / ccdt30;
            ccdt20 = DIW * 0.03086 / (THP);
            if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt20 - ccdt20) / ccdt20 > awuchai)
                {
                    acdt20 = ccdt20 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt20 = Math.Round(acdt20, 3);
            dwucha20 = 100 * (acdt20 - ccdt20) / ccdt20;
            //fwj20190812
            dli90 = ccdt90;
            dtime90 = acdt90;
            dwc90 = dwucha90;
            xianshitimeli90();
            xianshitimesj90();
            xianshitimewc90();
            ///fwj20190812
            dli80 = ccdt80;
            dtime80 = acdt80;
            dwc80 = dwucha80;
            xianshitimeli80();
            xianshitimesj80();
            xianshitimewc80();

            dli70 = ccdt70;
            dtime70 = acdt70;
            dwc70 = dwucha70;
            xianshitimeli70();
            xianshitimesj70();
            xianshitimewc70();

            dli60 = ccdt60;
            dtime60 = acdt60;
            dwc60 = dwucha60;
            xianshitimeli60();
            xianshitimesj60();
            xianshitimewc60();

            dli50 = ccdt50;
            dtime50 = acdt50;
            dwc50 = dwucha50;
            xianshitimeli50();
            xianshitimesj50();
            xianshitimewc50();

            dli40 = ccdt40;
            dtime40 = acdt40;
            dwc40 = dwucha40;
            xianshitimeli40();
            xianshitimesj40();
            xianshitimewc40();

            dli30 = ccdt30;
            dtime30 = acdt30;
            dwc30 = dwucha30;
            xianshitimeli30();
            xianshitimesj30();
            xianshitimewc30();

            dli20 = ccdt20;
            dtime20 = acdt20;
            dwc20 = dwucha20;
            xianshitimeli20();
            xianshitimesj20();
            xianshitimewc20();

            m_mainform.DAC.PutVol(1500);
            Thread.Sleep(2000);

            m_mainform.DAC.PutVol(0);

            ///记录检定数据
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\设备检定结果.ini";
            string path1 = string.Format(@"{0}", path);
            m_mainform.Ini(path1);

            m_mainform.Writue("ASM40恒加载检定", "加载功率", text_gonglv.Text);

            m_mainform.Writue("ASM40恒加载检定", "理论滑行时间", text_timell90.Text);
            m_mainform.Writue("ASM40恒加载检定", "实际滑行时间", text_timesj90.Text);
            m_mainform.Writue("ASM40恒加载检定", "相对误差", text_wucha90.Text);

            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed < 1)
                {
                    break;
                }
            }
            getlwsj(THP);
            ///记录检定数据      
            float fxdwc = 0;
            float.TryParse(text_wucha90.Text, out fxdwc);
            string spdjg = "合格";
            if (Math.Abs(fxdwc) > 4)
            {
                spdjg = "不合格";
            }
            string sjieguo = string.Format(@"加载功率{0};
                                                    90km/h理论滑行时间{1};
                                                    90km/h实际滑行时间{2};
                                                    90km/h相对误差{3};
                                                    80km/h理论滑行时间{4};
                                                    80km/h实际滑行时间{5};
                                                    80km/h相对误差{6};
                                                    70km/h理论滑行时间{7};
                                                    70km/h实际滑行时间{8};
                                                    70km/h相对误差{9};
                                                    60km/h理论滑行时间{10};
                                                    60km/h实际滑行时间{11};
                                                    60km/h相对误差{12};
                                                    50km/h理论滑行时间{13};
                                                    50km/h实际滑行时间{14};
                                                    50km/h相对误差{15};
                                                    40km/h理论滑行时间{16};
                                                    40km/h实际滑行时间{17};
                                                    40km/h相对误差{18};
                                                    30km/h理论滑行时间{19};
                                                    30km/h实际滑行时间{20};
                                                    30km/h相对误差{21};
                                                    20km/h理论滑行时间{22};
                                                    20km/h实际滑行时间{23};
                                                    20km/h相对误差{24};
                                                    {25}",
                                                    text_gonglv.Text,
                                                    text_timell90.Text,
                                                    text_timesj90.Text,
                                                    text_wucha90.Text,
                                                    text_timell80.Text,
                                                    text_timesj80.Text,
                                                    text_wucha80.Text,
                                                    text_timell70.Text,
                                                    text_timesj70.Text,
                                                    text_wucha70.Text,
                                                    text_timell60.Text,
                                                    text_timesj60.Text,
                                                    text_wucha60.Text,
                                                    text_timell50.Text,
                                                    text_timesj50.Text,
                                                    text_wucha50.Text,
                                                    text_timell40.Text,
                                                    text_timesj40.Text,
                                                    text_wucha40.Text,
                                                    text_timell30.Text,
                                                    text_timesj30.Text,
                                                    text_wucha30.Text,
                                                    text_timell20.Text,
                                                    text_timesj20.Text,
                                                    text_wucha20.Text,
            spdjg);
            string ssqlex = string.Format(@"insert into JDSJ (
                                               JDSJ_MC,
                                               JDSJ_JG,
                                               JDSJ_RQ,
JDSJ_JCX) values (
                                                '{0}',
                                                '{1}',
                                                '{2}',
                                                '{3}')",
                                         "柴油滑行",
                                         sjieguo,
                                         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                                 m_mainform.lineCode);
            //m_mainform.objbassLW.objdb.InsertDB(ssqlex);
        }

        private delegate void FlushClient();//代理
        private void xianshiGL()
        {
            if (this.text_gonglv.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiGL);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_gonglv.Text = string.Format(@"{0:N2}", fgonglv);
            }
        }
        private void xianshijzgl()
        {
            if (this.jiazaigonglv.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshijzgl);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.jiazaigonglv.Text = string.Format(@"{0}", ijzgl);
            }
        }

        private void xianshiSpeed()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiSpeed);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_sudu.Text = string.Format(@"{0:N2}", fspeed);
            }
        }

        private void xianshitimeli90()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli90);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell90.Text = string.Format(@"{0:N2}", dli90);
            }
        }

        private void xianshitimesj90()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj90);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj90.Text = string.Format(@"{0}", dtime90);
            }
        }
        //
        private void xianshitimewc90()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc90);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha90.Text = string.Format(@"{0:N3}", dwc90);
            }
        }

        //fwj20190812
        private void xianshitimeli80()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli80);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell80.Text = string.Format(@"{0:N2}", dli80);
            }
        }

        private void xianshitimesj80()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj80);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj80.Text = string.Format(@"{0}", dtime80);
            }
        }
        //
        private void xianshitimewc80()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc80);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha80.Text = string.Format(@"{0:N3}", dwc80);
            }
        }

        private void xianshitimeli70()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli70);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell70.Text = string.Format(@"{0:N2}", dli70);
            }
        }

        private void xianshitimesj70()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj70);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj70.Text = string.Format(@"{0}", dtime70);
            }
        }
        //
        private void xianshitimewc70()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc70);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha70.Text = string.Format(@"{0:N3}", dwc70);
            }
        }

        private void xianshitimeli60()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli60);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell60.Text = string.Format(@"{0:N2}", dli60);
            }
        }

        private void xianshitimesj60()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj60);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj60.Text = string.Format(@"{0}", dtime60);
            }
        }
        //
        private void xianshitimewc60()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc60);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha60.Text = string.Format(@"{0:N3}", dwc60);
            }
        }

        private void xianshitimeli50()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli50);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell50.Text = string.Format(@"{0:N2}", dli50);
            }
        }

        private void xianshitimesj50()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj50);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj50.Text = string.Format(@"{0}", dtime50);
            }
        }
        //
        private void xianshitimewc50()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc50);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha50.Text = string.Format(@"{0:N3}", dwc50);
            }
        }

        private void xianshitimeli40()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli40);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell40.Text = string.Format(@"{0:N2}", dli40);
            }
        }

        private void xianshitimesj40()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj40);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj40.Text = string.Format(@"{0}", dtime40);
            }
        }
        //
        private void xianshitimewc40()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc40);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha40.Text = string.Format(@"{0:N3}", dwc40);
            }
        }

        private void xianshitimeli30()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli30);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell30.Text = string.Format(@"{0:N2}", dli30);
            }
        }

        private void xianshitimesj30()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj30);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj30.Text = string.Format(@"{0}", dtime30);
            }
        }
        //
        private void xianshitimewc30()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc30);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha30.Text = string.Format(@"{0:N3}", dwc30);
            }
        }

        private void xianshitimeli20()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimeli20);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timell20.Text = string.Format(@"{0:N2}", dli20);
            }
        }

        private void xianshitimesj20()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimesj20);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_timesj20.Text = string.Format(@"{0}", dtime20);
            }
        }
        //
        private void xianshitimewc20()
        {
            if (this.text_sudu.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshitimewc20);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.text_wucha20.Text = string.Format(@"{0:N3}", dwc20);
            }
        }
        //DateTime datestart = new DateTime();
        DateTime datestart = DateTime.Now;
        model.尾气自检.cyhxsj objxljc = new model.尾气自检.cyhxsj();
        public void getlwsj(int thp)
        {
            try
            {
                objxljc.Checker = "";//skinCom_czy.Text;
                objxljc.CheckDate = DateTime.Now.ToString("yyyy-MM-dd");
                objxljc.SlideTimeStart = datestart.ToString("yyyy-MM-dd HH:mm:ss");
                objxljc.DIW = DIW.ToString();
                float sj90 = 0, sj80 = 0, sj70 = 0, sj60 = 0, sj50 = 0, sj40 = 0, sj30 = 0, sj20 = 0;
                float.TryParse(text_timesj90.Text, out sj90);
                float.TryParse(text_timesj80.Text, out sj80);
                float.TryParse(text_timesj70.Text, out sj70);
                float.TryParse(text_timesj60.Text, out sj60);
                float.TryParse(text_timesj50.Text, out sj50);
                float.TryParse(text_timesj40.Text, out sj40);
                float.TryParse(text_timesj30.Text, out sj30);
                float.TryParse(text_timesj20.Text, out sj20);
                sj90 = sj90 * 1000f;
                sj80 = sj80 * 1000f;
                sj70 = sj70 * 1000f;
                sj60 = sj60 * 1000f;
                sj50 = sj50 * 1000f;
                sj40 = sj40 * 1000f;
                sj30 = sj30 * 1000f;
                sj20 = sj20 * 1000f;


                float llsj90 = 0, llsj80 = 0, llsj70 = 0, llsj60 = 0, llsj50 = 0, llsj40 = 0, llsj30 = 0, llsj20 = 0;
                float.TryParse(text_timell90.Text, out llsj90);
                float.TryParse(text_timell80.Text, out llsj80);
                float.TryParse(text_timell70.Text, out llsj70);
                float.TryParse(text_timell60.Text, out llsj60);
                float.TryParse(text_timell50.Text, out llsj50);
                float.TryParse(text_timell40.Text, out llsj40);
                float.TryParse(text_timell30.Text, out llsj30);
                float.TryParse(text_timell20.Text, out llsj20);
                llsj90 = llsj90 * 1000f;
                llsj80 = llsj80 * 1000f;
                llsj70 = llsj70 * 1000f;
                llsj60 = llsj60 * 1000f;
                llsj50 = llsj50 * 1000f;
                llsj40 = llsj40 * 1000f;
                llsj30 = llsj30 * 1000f;
                llsj20 = llsj20 * 1000f;
                if (thp == 30)
                {

                    objxljc.IHP30ACDT90 = sj90.ToString("0");
                    objxljc.IHP30ACDT80 = sj80.ToString("0");
                    objxljc.IHP30ACDT70 = sj70.ToString("0");
                    objxljc.IHP30ACDT60 = sj60.ToString("0");
                    objxljc.IHP30ACDT50 = sj50.ToString("0");
                    objxljc.IHP30ACDT40 = sj40.ToString("0");
                    objxljc.IHP30ACDT30 = sj30.ToString("0");
                    objxljc.IHP30ACDT20 = sj20.ToString("0");

                    objxljc.IHP30CCDT90 = llsj90.ToString("0");
                    objxljc.IHP30CCDT80 = llsj80.ToString("0");
                    objxljc.IHP30CCDT70 = llsj70.ToString("0");
                    objxljc.IHP30CCDT60 = llsj60.ToString("0");
                    objxljc.IHP30CCDT50 = llsj50.ToString("0");
                    objxljc.IHP30CCDT40 = llsj40.ToString("0");
                    objxljc.IHP30CCDT30 = llsj30.ToString("0");
                    objxljc.IHP30CCDT20 = llsj20.ToString("0");
                }

                if (thp == 20)
                {
                    objxljc.IHP20ACDT90 = sj90.ToString("0");
                    objxljc.IHP20ACDT80 = sj80.ToString("0");
                    objxljc.IHP20ACDT70 = sj70.ToString("0");
                    objxljc.IHP20ACDT60 = sj60.ToString("0");
                    objxljc.IHP20ACDT50 = sj50.ToString("0");
                    objxljc.IHP20ACDT40 = sj40.ToString("0");
                    objxljc.IHP20ACDT30 = sj30.ToString("0");
                    objxljc.IHP20ACDT20 = sj20.ToString("0");

                    objxljc.IHP20CCDT90 = llsj90.ToString("0");
                    objxljc.IHP20CCDT80 = llsj80.ToString("0");
                    objxljc.IHP20CCDT70 = llsj70.ToString("0");
                    objxljc.IHP20CCDT60 = llsj60.ToString("0");
                    objxljc.IHP20CCDT50 = llsj50.ToString("0");
                    objxljc.IHP20CCDT40 = llsj40.ToString("0");
                    objxljc.IHP20CCDT30 = llsj30.ToString("0");
                    objxljc.IHP20CCDT20 = llsj20.ToString("0");
                }
                if (thp == 10)
                {

                    objxljc.IHP10ACDT90 = sj90.ToString("0");
                    objxljc.IHP10ACDT80 = sj80.ToString("0");
                    objxljc.IHP10ACDT70 = sj70.ToString("0");
                    objxljc.IHP10ACDT60 = sj60.ToString("0");
                    objxljc.IHP10ACDT50 = sj50.ToString("0");
                    objxljc.IHP10ACDT40 = sj40.ToString("0");
                    objxljc.IHP10ACDT30 = sj30.ToString("0");
                    objxljc.IHP10ACDT20 = sj20.ToString("0");

                    objxljc.IHP10CCDT90 = llsj90.ToString("0");
                    objxljc.IHP10CCDT80 = llsj80.ToString("0");
                    objxljc.IHP10CCDT70 = llsj70.ToString("0");
                    objxljc.IHP10CCDT60 = llsj60.ToString("0");
                    objxljc.IHP10CCDT50 = llsj50.ToString("0");
                    objxljc.IHP10CCDT40 = llsj40.ToString("0");
                    objxljc.IHP10CCDT30 = llsj30.ToString("0");
                    objxljc.IHP10CCDT20 = llsj20.ToString("0");
                }
                objxljc.PLHP90 = fplhp90.ToString("0.00");
                objxljc.PLHP80 = fplhp80.ToString("0.00");
                objxljc.PLHP70 = fplhp70.ToString("0.00");
                objxljc.PLHP60 = fplhp60.ToString("0.00");
                objxljc.PLHP50 = fplhp50.ToString("0.00");
                objxljc.PLHP40 = fplhp40.ToString("0.00");
                objxljc.PLHP30 = fplhp30.ToString("0.00");
                objxljc.PLHP20 = fplhp20.ToString("0.00");

                objxljc.SlideCheckJudge100 = "1";
                objxljc.SlideCheckJudge80 = "1";
                objxljc.CheckJudge = "1";
                // objxljc.Checker = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            string tph = "10";
            if (checkBox2.Checked)
            {
                tph = "20";
            }
            if (checkBox3.Checked)
            {
                tph = "30";
            }
            MessageBox.Show(m_mainform.objbass.uploadzj(tph,objxljc));

        }
        float fplhp90 = 0.4f;
        float fplhp80 = 0.4f;
        float fplhp70 = 0.4f;
        float fplhp60 = 0.4f;
        float fplhp50 = 0.4f;
        float fplhp40 = 0.4f;
        float fplhp30 = 0.4f;
        float fplhp20 = 0.4f;
        private void skinButton2_Click(object sender, EventArgs e)
        {

            model.尾气自检.cyfjgl objxljcex = new model.尾气自检.cyfjgl();
            objxljcex.CheckDate = DateTime.Now.ToString("yyyy-MM-dd");
            objxljcex.PLTimeStart = datestart.ToString("yyyy-MM-dd HH:mm:ss");
            objxljcex.SlideTimeEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            objxljcex.DIW = DIW.ToString();

            float sj90 = 0, sj80 = 0, sj70 = 0, sj60 = 0, sj50 = 0, sj40 = 0, sj30 = 0, sj20 = 0;
            float.TryParse(text_timesj90.Text, out sj90);
            float.TryParse(text_timesj80.Text, out sj80);
            float.TryParse(text_timesj70.Text, out sj70);
            float.TryParse(text_timesj60.Text, out sj60);
            float.TryParse(text_timesj50.Text, out sj50);
            float.TryParse(text_timesj40.Text, out sj40);
            float.TryParse(text_timesj30.Text, out sj30);
            float.TryParse(text_timesj20.Text, out sj20);
            sj90 = sj90 * 1000f;
            sj80 = sj80 * 1000f;
            sj70 = sj70 * 1000f;
            sj60 = sj60 * 1000f;
            sj50 = sj50 * 1000f;
            sj40 = sj40 * 1000f;
            sj30 = sj30 * 1000f;
            sj20 = sj20 * 1000f;

            objxljcex.ACDT90 = sj90.ToString("0");
            objxljcex.ACDT80 = sj80.ToString("0");
            objxljcex.ACDT70 = sj70.ToString("0");
            objxljcex.ACDT60 = sj60.ToString("0");
            objxljcex.ACDT50 = sj50.ToString("0");
            objxljcex.ACDT40 = sj40.ToString("0");
            objxljcex.ACDT30 = sj30.ToString("0");
            objxljcex.ACDT20 = sj20.ToString("0");
            objxljcex.PLHP90 = fplhp90.ToString("0.00");
            objxljcex.PLHP80 = fplhp80.ToString("0.00");
            objxljcex.PLHP70 = fplhp70.ToString("0.00");
            objxljcex.PLHP60 = fplhp60.ToString("0.00");
            objxljcex.PLHP50 = fplhp50.ToString("0.00");
            objxljcex.PLHP40 = fplhp40.ToString("0.00");
            objxljcex.PLHP30 = fplhp30.ToString("0.00");
            objxljcex.PLHP20 = fplhp20.ToString("0.00");
            objxljcex.CheckJudge = "1";
            objxljcex.Checker = skinCom_czy.Text;
            //Checker


            //iniclass objini = new iniclass();
            //string path = "";
            //path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            //string path1 = string.Format(@"{0}", path);
            //objini.Ini(path1);
            //objini.Writue("记录", "PLHP24", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP32", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP40", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP48", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP56", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP64", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP72", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP80", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());
            //objini.Writue("记录", "PLHP88", (((float)m_mainform.getRandom(1, 8)) * 0.1f).ToString());

            MessageBox.Show(m_mainform.objbass.uploadzj(objxljcex));
        }

        model.尾气自检.zjgcsj objgcsjhx = new model.尾气自检.zjgcsj();
        model.尾气自检.zjgcsj objgcsjnz = new model.尾气自检.zjgcsj();
        private void skinButton3_Click(object sender, EventArgs e)
        {
            objgcsjnz = new model.尾气自检.zjgcsj();
            gettongdao();
            m_mainform.DAC.tiaoling(1);//调零
             m_mainform.DAC.Lift(false);
            Thread.Sleep(1500);

            ///读取检定数据
            string path = "";
            string path2 = "";

            path = System.Windows.Forms.Application.StartupPath + path + "\\检测设备信息设置.ini";
            string path1 = string.Format(@"{0}", path);
            m_mainform.Ini(path1);

            float.TryParse(m_mainform.ReadValue("检测设备信息", "台架惯量"), out DIW);
            if (DIW < 1)
            {
                DIW = 900;
            }
            path2 = System.Windows.Forms.Application.StartupPath + path2 + "\\检测要求设置.ini";
            string path3 = string.Format(@"{0}", path2);
            m_mainform.Ini(path2);

            zijian = m_mainform.ReadValue("设置", "自检上传");

            float.TryParse(kaishispeed.Text, out fSpeedStrat);
            float.TryParse(jieshuspeed.Text, out fSpeedEnd);
            //20190713问题调解加载功率
            //khjz = 12f;

            btingzhi = false;
            t2 = new Thread(new ThreadStart(Thread2));
            t2.Priority = ThreadPriority.BelowNormal;
            t2.Start();
            //skinBut_ksjc.Enabled = false;
        }

        public void Thread2()
        {
            try
            {
                //for (int i = 1; i <= 3; i++)
                //{
                //    ijzgl = i * 10;
                //    xianshijzgl();
                //    int THP = 10;
                //    int.TryParse(jiazaigonglv.Text, out THP);
                    testfjgl();

                     //m_mainform.DAC.Lift(true);
                    //Thread.Sleep(3000);
                
            }
            catch
            {

            }
        }

        public void testfjgl()//恒加载测试
        {
            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);
            m_mainform.BianPinQi(true);
            Thread.Sleep(3000);
            m_mainform.BianPinQiSpeed(256 * 80);//设置频率加到100，设置到80
            float flichazhi = 0;

            dpinlv = DateTime.Now;
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed > fSpeedStrat + 3)
                {
                    m_mainform.BianPinQi(false); ;//关闭电源电源
                    m_mainform.BianPinQi(false); ;//关闭电源电源
                    m_mainform.BianPinQi(false); ;//关闭电源电源
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;

                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;
                //  xianshiGL();
                xianshiSpeed();
                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dFC[igcsj] = fForce;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);

                    igcsj++;
                    dpinlv = DateTime.Now;
                }



            }
            DateTime dstart = DateTime.Now;
            DateTime dend = DateTime.Now;
            dstartgcsj = DateTime.Now;
            DateTime start98 = new DateTime();
            DateTime start82 = new DateTime();
            DateTime start78 = new DateTime();
            DateTime start74 = new DateTime();
            DateTime start66 = new DateTime();
            DateTime start62 = new DateTime();
            DateTime start58 = new DateTime();
            DateTime start54 = new DateTime();
            DateTime start46 = new DateTime();
            DateTime start42 = new DateTime();
            DateTime start38 = new DateTime();
            DateTime start34 = new DateTime();
            DateTime start22 = new DateTime();
            DateTime start14 = new DateTime();

            //m_mainform.bdqxhb = true;
            DateTime dgcsjtime = DateTime.Now;
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (DateDiff(DateTime.Now, dgcsjtime) >= 900)
                {
                    dgcsjtime = DateTime.Now;
                    float fgtzs = m_fspeed * 1000000f / 3.1415926f / 216f / 60;
                    objgcsjnz.stringRpt.Add((int)fgtzs);//	int	转鼓转速r/min，测功机检查
                }
                if (m_fspeed <= fSpeedStrat)//80
                {
                    dstart = DateTime.Now;//记录开始滑行时间
                    //m_mainform.DAC.PutVol(200 * khjz);//开始加载  直接输出标定对应的数值 让第一次输出产生的力尽量接近设置的值
                    //break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;

                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;
                xianshiGL();
                xianshiSpeed();
                //fwj20190729

                if (m_fspeed >= 100)
                {
                    datestart = DateTime.Now;
                    start100 = DateTime.Now;
                }
                else if (m_fspeed >= 90)
                {
                    start90 = DateTime.Now;
                }
                else if (m_fspeed >= 80)
                {
                    start80 = DateTime.Now;
                }
                else if (m_fspeed >= 70)
                {
                    start70 = DateTime.Now;
                }
                else if (m_fspeed >= 60)
                {
                    start60 = DateTime.Now;
                }
                else if (m_fspeed >= 50)
                {
                    start50 = DateTime.Now;
                }
                else if (m_fspeed >= 40)
                {
                    start40 = DateTime.Now;
                }
                else if (m_fspeed >= 30)
                {
                    start30 = DateTime.Now;
                }
                else if (m_fspeed >= 20)
                {
                    start20 = DateTime.Now;
                }
                else if (m_fspeed >= 10)
                {
                    start10 = DateTime.Now;
                    //   m_mainform.DAC.PutVol(200 * khjz);//开始加载  直接输出标定对应的数值 让第一次输出产生的力尽量接近设置的值
                }
                else
                {
                    break;
                }
                if (m_fspeed >= 98)
                {
                    start98 = DateTime.Now;
                }
                if (m_fspeed >= 82)
                {
                    start82 = DateTime.Now;
                }
                if (m_fspeed >= 78)
                {
                    start78 = DateTime.Now;
                }
                if (m_fspeed >= 74)
                {
                    start74 = DateTime.Now;
                }
                if (m_fspeed >= 66)
                {
                    start66 = DateTime.Now;
                }
                if (m_fspeed >= 62)
                {
                    start62 = DateTime.Now;
                }
                if (m_fspeed >= 58)
                {
                    start58 = DateTime.Now;
                }
                if (m_fspeed >= 54)
                {
                    start54 = DateTime.Now;
                }
                if (m_fspeed >= 46)
                {
                    start46 = DateTime.Now;
                }
                if (m_fspeed >= 42)
                {
                    start42 = DateTime.Now;
                }
                if (m_fspeed >= 38)
                {
                    start38 = DateTime.Now;
                }
                if (m_fspeed >= 34)
                {
                    start34 = DateTime.Now;
                }
                if (m_fspeed >= 22)
                {
                    start22 = DateTime.Now;
                }
                if (m_fspeed >= 14)
                {
                    start14 = DateTime.Now;
                }

                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dFC[igcsj] = fForce;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;

                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);
                    igcsj++;
                    dpinlv = DateTime.Now;
                }
            }
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed <= fSpeedEnd)
                {//记录结束滑行时间
                    dend = DateTime.Now;
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;
                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;

                xianshiGL();
                xianshiSpeed();



                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dPW[igcsj] = 0;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    dFC[igcsj] = fForce;


                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);
                    //  WriteGraph(zedGraphControl1, dSP, dFC, igcsj + 1);

                    igcsj++;
                    dpinlv = DateTime.Now;
                }


            }

            //m_mainform.bdqxhb = false;
            fspeed = 0;
            xianshiSpeed();

            double acdt = 0;
            double acdt90 = 0;
            double acdt80 = 0;
            double acdt70 = 0;
            double acdt60 = 0;
            double acdt50 = 0;
            double acdt40 = 0;
            double acdt30 = 0;
            double acdt20 = 0;
            acdt = DateDiff(dend, dstart) * 0.001;
            acdt90 = DateDiff(start100, start80) * 0.001;
            acdt80 = DateDiff(start90, start70) * 0.001;
            acdt70 = DateDiff(start80, start60) * 0.001;
            acdt60 = DateDiff(start70, start50) * 0.001;
            acdt50 = DateDiff(start60, start40) * 0.001;
            acdt40 = DateDiff(start50, start30) * 0.001;
            acdt30 = DateDiff(start40, start20) * 0.001;
            acdt20 = DateDiff(start30, start10) * 0.001;


            acdt90 = Math.Round(acdt90, 3);
            acdt80 = Math.Round(acdt80, 3);
            acdt70 = Math.Round(acdt70, 3);
            acdt60 = Math.Round(acdt60, 3);
            acdt50 = Math.Round(acdt50, 3);
            acdt40 = Math.Round(acdt40, 3);
            acdt30 = Math.Round(acdt30, 3);
            acdt20 = Math.Round(acdt20, 3);

            fplhp90 = DIW * ((float)Math.Pow(100f / 3.6f, 2) - (float)Math.Pow(80f / 3.6f, 2)) / 2000f / (float)acdt90;
            fplhp80 = DIW * ((float)Math.Pow(90f / 3.6f, 2) - (float)Math.Pow(70f / 3.6f, 2)) / 2000f / (float)acdt80;
            fplhp70 = DIW * ((float)Math.Pow(80f / 3.6f, 2) - (float)Math.Pow(60f / 3.6f, 2)) / 2000f / (float)acdt70;
            fplhp60 = DIW * ((float)Math.Pow(70f / 3.6f, 2) - (float)Math.Pow(50f / 3.6f, 2)) / 2000f / (float)acdt60;
            fplhp50 = DIW * ((float)Math.Pow(60f / 3.6f, 2) - (float)Math.Pow(40f / 3.6f, 2)) / 2000f / (float)acdt50;
            fplhp40 = DIW * ((float)Math.Pow(50f / 3.6f, 2) - (float)Math.Pow(30f / 3.6f, 2)) / 2000f / (float)acdt40;
            fplhp30 = DIW * ((float)Math.Pow(40f / 3.6f, 2) - (float)Math.Pow(20f / 3.6f, 2)) / 2000f / (float)acdt30;
            fplhp20 = DIW * ((float)Math.Pow(30f / 3.6f, 2) - (float)Math.Pow(10f / 3.6f, 2)) / 2000f / (float)acdt20;


            this.Invoke(new Action(() => { this.lbl90sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl80sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl70sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl60sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl50sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl40sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl30sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl20sj.Text = "附加损失功率"; }));

            this.Invoke(new Action(() => { this.text_timell90.Text = fplhp90.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell80.Text = fplhp80.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell70.Text = fplhp70.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell60.Text = fplhp60.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell50.Text = fplhp50.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell40.Text = fplhp40.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell30.Text = fplhp30.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell20.Text = fplhp20.ToString("0.00"); }));

            {
                iniclass objini = new iniclass();
                objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
                objini.Writue("柴油附加功率", "开始滑行时间", dstart.ToString("yyyy-MM-dd HH:mm:ss"));
                objini.Writue("柴油附加功率", "结束滑行时间", dend.ToString("yyyy-MM-dd HH:mm:ss"));
                objini.Writue("柴油附加功率", "惯量", DIW.ToString());
                objini.Writue("柴油附加功率", "PLHP90", fplhp90.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP80", fplhp80.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP70", fplhp70.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP60", fplhp60.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP50", fplhp50.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP40", fplhp40.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP30", fplhp30.ToString("0.00"));
                objini.Writue("柴油附加功率", "PLHP20", fplhp20.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间90km/h", acdt90.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间80km/h", acdt80.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间70km/h", acdt70.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间60km/h", acdt60.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间50km/h", acdt50.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间40km/h", acdt40.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间30km/h", acdt30.ToString("0.00"));
                objini.Writue("柴油附加功率", "实际滑行时间20km/h", acdt20.ToString("0.00"));
                objini.Writue("柴油附加功率", "检定时间", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }

            objgcsjnz.dtCheckDate = dstart.ToString("yyyy-MM-dd");
            objgcsjnz.dtBeginTime = dstart.ToString("yyyy-MM-dd HH:mm:ss");
            objgcsjnz.dtEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string sjieguo = string.Format(@"90km/h附加功率{0};
90km/h滑行时间{1};
80km/h附加功率{2};
80km/h滑行时间{3};
70km/h附加功率{4};
70km/h滑行时间{5};
60km/h附加功率{6};
60km/h滑行时间{7};
50km/h附加功率{8};
50km/h滑行时间{9};
40km/h附加功率{10};
40km/h滑行时间{11};
30km/h附加功率{12};
30km/h滑行时间{13};
20km/h附加功率{14};
20km/h滑行时间{15};",
                                                         fplhp90.ToString("0.00"), acdt90.ToString("0.000"),
                                                         fplhp80.ToString("0.00"), acdt80.ToString("0.000"),
                                                         fplhp70.ToString("0.00"), acdt70.ToString("0.000"),
                                                         fplhp60.ToString("0.00"), acdt60.ToString("0.000"),
                                                         fplhp50.ToString("0.00"), acdt50.ToString("0.000"),
                                                         fplhp40.ToString("0.00"), acdt40.ToString("0.000"),
                                                         fplhp30.ToString("0.00"), acdt30.ToString("0.000"),
                                                         fplhp20.ToString("0.00"), acdt20.ToString("0.000")
            );
            string ssqlex = string.Format(@"insert into JDSJ (
                                               JDSJ_MC,
                                               JDSJ_JG,
                                               JDSJ_RQ,
JDSJ_JCX) values (
                                                '{0}',
                                                '{1}',
                                                '{2}',
                                                '{3}')",
                                         "柴油附加功率",
                                         sjieguo,
                                         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                                 m_mainform.lineCode);
            m_mainform.objbassLW.objdb.InsertDB(ssqlex);
            //fwj20190812
            //dli90 = ccdt90;
            dtime90 = acdt90;
            //dwc90 = dwucha90;
            xianshitimeli90();
            xianshitimesj90();
            xianshitimewc90();
            ///fwj20190812
            //dli80 = ccdt80;
            dtime80 = acdt80;
            //dwc80 = dwucha80;
            xianshitimeli80();
            xianshitimesj80();
            xianshitimewc80();

            //dli70 = ccdt70;
            dtime70 = acdt70;
            //dwc70 = dwucha70;
            xianshitimeli70();
            xianshitimesj70();
            xianshitimewc70();

            //dli60 = ccdt60;
            dtime60 = acdt60;
            //dwc60 = dwucha60;
            xianshitimeli60();
            xianshitimesj60();
            xianshitimewc60();

            //dli50 = ccdt50;
            dtime50 = acdt50;
            //dwc50 = dwucha50;
            xianshitimeli50();
            xianshitimesj50();
            xianshitimewc50();

            //dli40 = ccdt40;
            dtime40 = acdt40;
            //dwc40 = dwucha40;
            xianshitimeli40();
            xianshitimesj40();
            xianshitimewc40();

            //dli30 = ccdt30;
            dtime30 = acdt30;
            //dwc30 = dwucha30;
            xianshitimeli30();
            xianshitimesj30();
            xianshitimewc30();

            //dli20 = ccdt20;
            dtime20 = acdt20;
            //dwc20 = dwucha20;
            xianshitimeli20();
            xianshitimesj20();
            xianshitimewc20();

            m_mainform.DAC.PutVol(1500);
            Thread.Sleep(2000);

            m_mainform.DAC.PutVol(0);


            this.Invoke(new Action(() => { this.lbl90sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl80sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl70sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl60sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl50sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl40sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl30sj.Text = "附加损失功率"; }));
            this.Invoke(new Action(() => { this.lbl20sj.Text = "附加损失功率"; }));

            this.Invoke(new Action(() => { this.text_timell90.Text = fplhp90.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell80.Text = fplhp80.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell70.Text = fplhp70.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell60.Text = fplhp60.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell50.Text = fplhp50.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell40.Text = fplhp40.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell30.Text = fplhp30.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell20.Text = fplhp20.ToString("0.00"); }));

            //-----------------------------------------------

            double dPLHP24 = Math.Round(DIW * (Math.Pow(34f / 3.6f, 2) - Math.Pow(14f / 3.6f, 2)) / 2000 / (DateDiff(start34, start14) * 0.001), 2);
            double dPLHP32 = Math.Round(DIW * (Math.Pow(42f / 3.6f, 2) - Math.Pow(22f / 3.6f, 2)) / 2000 / (DateDiff(start42, start22) * 0.001), 2);
            double dPLHP40 = Math.Round(DIW * (Math.Pow(50f / 3.6f, 2) - Math.Pow(30f / 3.6f, 2)) / 2000 / (DateDiff(start50, start30) * 0.001), 2);
            double dPLHP48 = Math.Round(DIW * (Math.Pow(58f / 3.6f, 2) - Math.Pow(38f / 3.6f, 2)) / 2000 / (DateDiff(start58, start38) * 0.001), 2);
            double dPLHP56 = Math.Round(DIW * (Math.Pow(66f / 3.6f, 2) - Math.Pow(46f / 3.6f, 2)) / 2000 / (DateDiff(start66, start46) * 0.001), 2);
            double dPLHP64 = Math.Round(DIW * (Math.Pow(74f / 3.6f, 2) - Math.Pow(54f / 3.6f, 2)) / 2000 / (DateDiff(start74, start54) * 0.001), 2);
            double dPLHP72 = Math.Round(DIW * (Math.Pow(82f / 3.6f, 2) - Math.Pow(62f / 3.6f, 2)) / 2000 / (DateDiff(start82, start62) * 0.001), 2);
            double dPLHP80 = Math.Round(DIW * (Math.Pow(90f / 3.6f, 2) - Math.Pow(70f / 3.6f, 2)) / 2000 / (DateDiff(start90, start70) * 0.001), 2);
            double dPLHP88 = Math.Round(DIW * (Math.Pow(98f / 3.6f, 2) - Math.Pow(78f / 3.6f, 2)) / 2000 / (DateDiff(start98, start78) * 0.001), 2);
            {

                iniclass objini = new iniclass();
                string path = "";
                path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
                string path1 = string.Format(@"{0}", path);
                objini.Ini(path1);
                objini.Writue("记录", "PLHP24时间", (DateDiff(start34, start14) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP32时间", (DateDiff(start42, start22) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP40时间", (DateDiff(start50, start30) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP48时间", (DateDiff(start58, start38) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP56时间", (DateDiff(start66, start46) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP64时间", (DateDiff(start74, start54) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP72时间", (DateDiff(start82, start62) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP80时间", (DateDiff(start90, start70) * 0.001).ToString("0.000"));
                objini.Writue("记录", "PLHP88时间", (DateDiff(start98, start78) * 0.001).ToString("0.000"));

                objini.Writue("记录", "PLHP24", dPLHP24.ToString("0.00"));
                objini.Writue("记录", "PLHP32", dPLHP32.ToString("0.00"));
                objini.Writue("记录", "PLHP40", dPLHP40.ToString("0.00"));
                objini.Writue("记录", "PLHP48", dPLHP48.ToString("0.00"));
                objini.Writue("记录", "PLHP56", dPLHP56.ToString("0.00"));
                objini.Writue("记录", "PLHP64", dPLHP64.ToString("0.00"));
                objini.Writue("记录", "PLHP72", dPLHP72.ToString("0.00"));
                objini.Writue("记录", "PLHP80", dPLHP80.ToString("0.00"));
                objini.Writue("记录", "PLHP88", dPLHP88.ToString("0.00"));

            }
            //---------------------------------------------------------------------------------------------

            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed < 1)
                {
                    break;
                }
            }

            // m_mainform.DAC.Lift(true);

        }

        private void skinButton4_Click(object sender, EventArgs e)
        {
            gettongdao();
            //m_mainform.DAC.tiaoling(1);//调零
            // m_mainform.DAC.Lift(false);
            //Thread.Sleep(1500);

            ///读取检定数据
            string path = "";
            string path2 = "";
            //path = System.Windows.Forms.Application.StartupPath + path + "\\设备检定结果.ini";
            //string path1 = string.Format(@"{0}", path);
            //m_mainform.Ini(path1);

            //float.TryParse(m_mainform.ReadValue("惯量检定", "惯量"), out DIW);

            path = System.Windows.Forms.Application.StartupPath + path + "\\检测设备信息设置.ini";
            string path1 = string.Format(@"{0}", path);
            m_mainform.Ini(path1);

            float.TryParse(m_mainform.ReadValue("检测设备信息", "台架惯量"), out DIW);
            if (DIW < 1)
            {
                DIW = 900;
            }
            path2 = System.Windows.Forms.Application.StartupPath + path2 + "\\检测要求设置.ini";
            string path3 = string.Format(@"{0}", path2);
            m_mainform.Ini(path2);

            zijian = m_mainform.ReadValue("设置", "自检上传");

            float.TryParse(kaishispeed.Text, out fSpeedStrat);
            float.TryParse(jieshuspeed.Text, out fSpeedEnd);
            //20190713问题调解加载功率
            //khjz = 12f;

            btingzhi = false;
            hjz();
            jshegesj(10);
            jshegesj(20);
            jshegesj(30);

        }
        //柴油恒加载
        public void hjz()
        {
            double dccdt40 = 0.04938 * DIW / 6;
            dccdt40 = Math.Round(dccdt40, 2);

            double accdt40 = 0;
            double dwcccdt40 = m_mainform.getRandom(1, 7) - 4 + ((float)m_mainform.getRandom(1, 7)) * 0.1f + ((float)m_mainform.getRandom(1, 7)) * 0.01f;
            dwcccdt40 = Math.Round(dwcccdt40,2);
            //double dwcccdt40 = (accdt40 - dccdt40) / dccdt40 * 100;
            accdt40 = dwcccdt40 / 100 * dccdt40 + dccdt40;
            accdt40 = Math.Round(accdt40, 2);
            dwcccdt40 = (accdt40 - dccdt40) / dccdt40 * 100;
            dwcccdt40 = Math.Round(dwcccdt40, 2);

            double dccdt56 = 0.06914 * DIW / 6;
            dccdt56 = Math.Round(dccdt56, 2);
            double accdt56 = 0;
            //double dwcccdt56 = (accdt56 - dccdt56) / dccdt56 * 100;
            double dwcccdt56 = m_mainform.getRandom(0, 7) - 4 + ((float)m_mainform.getRandom(1, 7)) * 0.1f + ((float)m_mainform.getRandom(1, 7)) * 0.01f;
            accdt56 = dwcccdt56 / 100 * dccdt56 + dccdt56;
            accdt56 = Math.Round(accdt56, 2);
            dwcccdt56 = (accdt56 - dccdt56) / dccdt56 * 100;
            dwcccdt56 = Math.Round(dwcccdt56, 2);

            accdt40 = accdt40 * 1000;
            dccdt40 = dccdt40 * 1000;
            accdt56 = accdt56 * 1000;
            dccdt56 = dccdt56 * 1000;
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            objini.Writue("记录", "ACDT40", accdt40.ToString("0"));
            objini.Writue("记录", "CCDT40", dccdt40.ToString("0"));
            objini.Writue("记录", "CDT40_Error",dwcccdt40.ToString());
            objini.Writue("记录", "CDT40_Judge","1");
            objini.Writue("记录", "ACDT56", accdt56.ToString("0"));
            objini.Writue("记录", "CCDT56",dccdt56.ToString("0"));
            objini.Writue("记录", "CDT56_Error",dwcccdt56.ToString());
            objini.Writue("记录", "CDT56_Judge","1");

        }
        public void jshegesj(int THP)
        {



            double acdt90 = 0;
            double acdt80 = 0;
            double acdt70 = 0;
            double acdt60 = 0;
            double acdt50 = 0;
            double acdt40 = 0;
            double acdt30 = 0;
            double acdt20 = 0;
            //acdt = DateDiff(dend, dstart) * 0.001;
            //acdt90 = DateDiff(start100, start80) * 0.001;
            //acdt80 = DateDiff(start90, start70) * 0.001;
            //acdt70 = DateDiff(start80, start60) * 0.001;
            //acdt60 = DateDiff(start70, start50) * 0.001;
            //acdt50 = DateDiff(start60, start40) * 0.001;
            //acdt40 = DateDiff(start50, start30) * 0.001;
            //acdt30 = DateDiff(start40, start20) * 0.001;
            //acdt20 = DateDiff(start30, start10) * 0.001;

            double dwucha90 = 0;
            double dwucha80 = 0;
            double dwucha70 = 0;
            double dwucha60 = 0;
            double dwucha50 = 0;
            double dwucha40 = 0;
            double dwucha30 = 0;
            double dwucha20 = 0;
            double ccdt90 = 0;
            double ccdt80 = 0;
            double ccdt70 = 0;
            double ccdt60 = 0;
            double ccdt50 = 0;
            double ccdt40 = 0;
            double ccdt30 = 0;
            double ccdt20 = 0;

            double awuchai = 0.2;
            if (THP < 1)
            {
                THP = 10;
            }
            if (THP == 10 || THP == 20)
            {
                awuchai = 0.02;
            }
            else
            {
                awuchai = 0.04;
            }


            //100~80理论;ccdt=DIW*0.138889/(THP)
            //90~70理论;DIW*0.12345679/(THP)
            //80~60理论;DIW*0.108024691/(THP)
            //70~50理论;DIW*0.09259/(THP)
            //60~40理论;DIW*0.07716049/(THP)
            //50~30理论:ccdt=DIW*0.06173/(THP)
            //40~20理论;ccdt=DIW*0.046296/(THP)
            //30~10理论;ccdt=DIW*0.030864198/(THP)
            //35~15理论:ccdt=DIW*0.03858/(THP)
            ////////////
            ccdt90 = DIW * 0.13888 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt90 - ccdt90) / ccdt90 > awuchai)
                {
                    acdt90 = ccdt90 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt90 = Math.Round(acdt90, 3);
            dwucha90 = 100 * (acdt90 - ccdt90) / ccdt90;
            /////
            ccdt80 = DIW * 0.12345 / (THP);
            //if (zijian.Contains("是"))
            {
                if ((Math.Abs(acdt80 - ccdt80)) / ccdt80 > awuchai)
                {
                    acdt80 = ccdt80 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt80 = Math.Round(acdt80, 3);
            dwucha80 = 100 * (acdt80 - ccdt80) / ccdt80;
            ccdt70 = DIW * 0.10802 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt70 - ccdt70) / ccdt70 > awuchai)
                {
                    acdt70 = ccdt70 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt70 = Math.Round(acdt70, 3);
            dwucha70 = 100 * (acdt70 - ccdt70) / ccdt70;
            ccdt60 = DIW * 0.09259 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt60 - ccdt60) / ccdt60 > awuchai)
                {
                    acdt60 = ccdt60 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt60 = Math.Round(acdt60, 3);
            dwucha60 = 100 * (acdt60 - ccdt60) / ccdt60;
            ccdt50 = DIW * 0.07716 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt50 - ccdt50) / ccdt50 > awuchai)
                {
                    acdt50 = ccdt50 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt50 = Math.Round(acdt50, 3);
            dwucha50 = 100 * (acdt50 - ccdt50) / ccdt50;
            ccdt40 = DIW * 0.06173 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt40 - ccdt40) / ccdt40 > awuchai)
                {
                    acdt40 = ccdt40 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt40 = Math.Round(acdt40, 3);
            dwucha40 = 100 * (acdt40 - ccdt40) / ccdt40;
            ccdt30 = DIW * 0.04629 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt30 - ccdt30) / ccdt30 > awuchai)
                {
                    acdt30 = ccdt30 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt30 = Math.Round(acdt30, 3);
            dwucha30 = 100 * (acdt30 - ccdt30) / ccdt30;
            ccdt20 = DIW * 0.03086 / (THP);
            //if (zijian.Contains("是"))
            {
                if (Math.Abs(acdt20 - ccdt20) / ccdt20 > awuchai)
                {
                    acdt20 = ccdt20 * 0.98 + m_mainform.getRandom(0, 9) * 0.01;
                }
            }
            acdt20 = Math.Round(acdt20, 3);
            dwucha20 = 100 * (acdt20 - ccdt20) / ccdt20;
            //fwj20190812
            dli90 = ccdt90;
            dtime90 = acdt90;
            dwc90 = dwucha90;
            xianshitimeli90();
            xianshitimesj90();
            xianshitimewc90();
            ///fwj20190812
            dli80 = ccdt80;
            dtime80 = acdt80;
            dwc80 = dwucha80;
            xianshitimeli80();
            xianshitimesj80();
            xianshitimewc80();

            dli70 = ccdt70;
            dtime70 = acdt70;
            dwc70 = dwucha70;
            xianshitimeli70();
            xianshitimesj70();
            xianshitimewc70();

            dli60 = ccdt60;
            dtime60 = acdt60;
            dwc60 = dwucha60;
            xianshitimeli60();
            xianshitimesj60();
            xianshitimewc60();

            dli50 = ccdt50;
            dtime50 = acdt50;
            dwc50 = dwucha50;
            xianshitimeli50();
            xianshitimesj50();
            xianshitimewc50();

            dli40 = ccdt40;
            dtime40 = acdt40;
            dwc40 = dwucha40;
            xianshitimeli40();
            xianshitimesj40();
            xianshitimewc40();

            dli30 = ccdt30;
            dtime30 = acdt30;
            dwc30 = dwucha30;
            xianshitimeli30();
            xianshitimesj30();
            xianshitimewc30();

            dli20 = ccdt20;
            dtime20 = acdt20;
            dwc20 = dwucha20;
            xianshitimeli20();
            xianshitimesj20();
            xianshitimewc20();

            //m_mainform.DAC.PutVol(1500);
            //Thread.Sleep(2000);

            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);

            /////记录检定数据
            //string path = "";
            //path = System.Windows.Forms.Application.StartupPath + path + "\\设备检定结果.ini";
            //string path1 = string.Format(@"{0}", path);
            //m_mainform.Ini(path1);

            //m_mainform.Writue("ASM40恒加载检定", "加载功率", text_gonglv.Text);

            //m_mainform.Writue("ASM40恒加载检定", "理论滑行时间", text_timell90.Text);
            //m_mainform.Writue("ASM40恒加载检定", "实际滑行时间", text_timesj90.Text);
            //m_mainform.Writue("ASM40恒加载检定", "相对误差", text_wucha90.Text);

            getlwsj(THP);
        }

        private void JDHuaXing_FormClosing(object sender, FormClosingEventArgs e)
        {

            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);
            m_mainform.BianPinQi(false);
        }

        bool keybool = false;
        private void label8_MouseClick(object sender, MouseEventArgs e)
        {

            if (e.Button == MouseButtons.Right && keybool)// && KeyDown ==Keys.Shift )
            {
                skinButton4.Visible = true;
                keybool = false;
            }
        }

        private void JDHuaXing_KeyUp(object sender, KeyEventArgs e)
        {

            keybool = false;
        }

        private void JDHuaXing_KeyDown(object sender, KeyEventArgs e)
        {

            if (e.Shift)
                keybool = true;
        }

        private void JDHuaXing_Load(object sender, EventArgs e)
        {
            iniCZY("CZY");
            textBox1.Text = m_mainform.stationCode;
            textBox2.Text = m_mainform.lineCode;
            textBox3.Text = DateTime.Now.ToString("yyyy-MM-dd");
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\检测参数设置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);

            float.TryParse(objini.ReadValue("设置", "柴油滑行系数"), out khjz);
        }
        public void iniCZY(string dataname)
        {
            string ssqlex = "";
            //ssqlex = string.Format(@"select * from {0}", dataname);
            ssqlex = string.Format(@"select * from Employee where EP_TYPE ='引车员'");
            DataTable dt = m_mainform.objbass.objdb.GetTable(ssqlex);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                skinCom_czy.Items.Add(dt.Rows[i]["EP_NAME"].ToString().Trim());
                if (i == 0)
                    skinCom_czy.Text = dt.Rows[0]["EP_NAME"].ToString().Trim();
            }
        }

        //wwt20200529 新自检流程


        public void getpow(float start, float end, float diw, int szpow)
        {
            //float fnz50 = 0, fnz40 = 0, fnz30 = 0;
            //{
            //    iniclass objini = new iniclass();
            //    objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
            //    float.TryParse(objini.ReadValue("内阻检定", "50内阻"), out fnz50);
            //    float.TryParse(objini.ReadValue("内阻检定", "40内阻"), out fnz40);
            //    float.TryParse(objini.ReadValue("内阻检定", "30内阻"), out fnz30);
            //}
            DateTime dend;
            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);
            m_mainform.BianPinQi(true);
            Thread.Sleep(3000);
            m_mainform.BianPinQiSpeed(256 * 40);//设置频率
            float flichazhi = 0;

            dpinlv = DateTime.Now;
            #region 加速到108
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed > start + 8)
                {
                    m_mainform.BianPinQi(false); ;//关闭电源电源
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;

                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;
                //  xianshiGL();
                xianshiSpeed();
                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dFC[igcsj] = fForce;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);


                    igcsj++;
                    dpinlv = DateTime.Now;
                }

            }
            #endregion
            Thread.Sleep(1000);
            DateTime dstart10 = DateTime.Now;
            DateTime dstart20 = DateTime.Now;
            DateTime dstart30 = DateTime.Now;
            DateTime dstart40 = DateTime.Now;
            DateTime dstart50 = DateTime.Now;
            DateTime dstart60 = DateTime.Now;
            DateTime dstart70 = DateTime.Now;
            DateTime dstart80 = DateTime.Now;
            DateTime dstart90 = DateTime.Now;
            DateTime dstart100 = DateTime.Now;
            //Thread.Sleep(100);
            m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
            float m_fspeedlast = m_fspeed;
            DateTime dtwoliusj = DateTime.Now;
            float fgljiazai = 0;
            //float.TryParse(pow.Text, out fgljiazai);
            fgljiazai = szpow;
            float fmz = 0;
            float izzmz = 0;

            float fnz90 = 0;
            float fnz80 = 0;
            float fnz70 = 0;
            float fnz60 = 0;
            float fnz50 = 0;
            float fnz40 = 0;
            float fnz30 = 0;
            float fnz20 = 0;
            float fnzjs = 0;

            float fzzmz100 = 0;
            float fzzmz95 = 0;
            float fzzmz90 = 0;
            float fzzmz85 = 0;
            float fzzmz80 = 0;
            float fzzmz75 = 0;
            float fzzmz70 = 0;
            float fzzmz65 = 0;
            float fzzmz60 = 0;
            float fzzmz55 = 0;
            float fzzmz50 = 0;
            float fzzmz45 = 0;
            float fzzmz40 = 0;
            float fzzmz35 = 0;
            float fzzmz30 = 0;
            float fzzmz25 = 0;
            float fzzmz20 = 0;
            float fzzmz15 = 0;
            float fzzmz10 = 0;
            float fzzmz5 = 0;
            bool bzxs = false;

            {
                iniclass objini = new iniclass();
                objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP90"), out fnz90);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP80"), out fnz80);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP70"), out fnz70);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP60"), out fnz60);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP50"), out fnz50);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP40"), out fnz40);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP30"), out fnz30);
                float.TryParse(objini.ReadValue("柴油附加功率", "PLHP20"), out fnz20);
                //float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString()), out izzmz);

                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "100"), out  fzzmz100);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "95"), out  fzzmz95);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "80"), out  fzzmz90);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "85"), out  fzzmz85);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "80"), out  fzzmz80);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "75"), out  fzzmz75);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "70"), out  fzzmz70);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "65"), out  fzzmz65);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "60"), out  fzzmz60);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "55"), out  fzzmz55);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "50"), out  fzzmz50);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "45"), out  fzzmz45);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "40"), out  fzzmz40);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "35"), out  fzzmz35);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "30"), out  fzzmz30);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "25"), out  fzzmz25);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "20"), out  fzzmz20);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "15"), out  fzzmz15);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "10"), out  fzzmz10);
                float.TryParse(objini.ReadValue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "5"), out  fzzmz5);
                if (fzzmz100 == 0 && fzzmz90 == 0 && fzzmz80 == 0 && fzzmz70 == 0 && fzzmz60 == 0 && fzzmz50 == 0)
                {
                    bzxs = true;
                }
            }
            DateTime dgcsjtime = DateTime.Now;
            while (true)
            {
                Thread.Sleep(10);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (DateDiff(DateTime.Now, dgcsjtime) >= 900)
                {
                    dgcsjtime = DateTime.Now;
                    float fgtzs = m_fspeed * 1000000f / 3.1415926f / 216f / 60;
                    objgcsjhx.stringRpt.Add((int)fgtzs);//	int	转鼓转速r/min，测功机检查
                    objgcsjhx.stringLodVal.Add(szpow);//	float	测功机加载负荷kw，测功机检查
                }
                if (m_fspeed >= 100) { dstart100 = DateTime.Now; }
                if (m_fspeed >= 90) { dstart90 = DateTime.Now; }
                if (m_fspeed >= 80) { dstart80 = DateTime.Now; }
                if (m_fspeed >= 70) { dstart70 = DateTime.Now; }
                if (m_fspeed >= 60) { dstart60 = DateTime.Now; }
                if (m_fspeed >= 50) { dstart50 = DateTime.Now; }
                if (m_fspeed >= 40) { dstart40 = DateTime.Now; }
                if (m_fspeed >= 30) { dstart30 = DateTime.Now; }
                if (m_fspeed >= 20) { dstart20 = DateTime.Now; }
                if (m_fspeed >= 10) { dstart10 = DateTime.Now; }

                if (m_fspeed > 90) { fnzjs = fnz90; }
                else if (m_fspeed > 80) { fnzjs = fnz80; }
                else if (m_fspeed > 70) { fnzjs = fnz70; }
                else if (m_fspeed > 60) { fnzjs = fnz60; }
                else if (m_fspeed > 50) { fnzjs = fnz50; }
                else if (m_fspeed > 40) { fnzjs = fnz40; }
                else if (m_fspeed > 30) { fnzjs = fnz30; }
                else if (m_fspeed > 20) { fnzjs = fnz20; }
                else { fnzjs = 0; }
                if (m_fspeed <= 6)
                {//记录结束滑行时间
                    dend = DateTime.Now;
                    break;
                }
                flichazhi = fForce;
                if (flichazhi < 0)
                    flichazhi = 0;
                fgonglv = (flichazhi * m_fspeed) / 360;
                fspeed = m_fspeed;

                xianshiGL();
                xianshiSpeed();

                if (DateDiff(DateTime.Now, dtwoliusj) >= 300)
                {
                    float forcedq, forcejs;
                    forcedq = fForce;
                    forcejs = m_mainform.DAC.getcyz("涡流输出", fmz);
                    float fblz = 0;
                    if (m_fspeed < fSpeedStrat + 6)
                    {
                        fblz = getbljj(forcedq, forcejs);
                    }
                    float fgonglvjs = 0;

                    {
                        if (m_fspeed >= 100) { fzzmz100 += fblz; izzmz = fzzmz100; }
                        else if (m_fspeed >= 95) { if (bzxs && Math.Abs(fzzmz95) < 1) { fzzmz95 = fzzmz100; } fzzmz95 += fblz; izzmz = fzzmz95; }
                        else if (m_fspeed >= 90) { if (bzxs && Math.Abs(fzzmz90) < 1) { fzzmz90 = fzzmz95; } fzzmz90 += fblz; izzmz = fzzmz90; }
                        else if (m_fspeed >= 85) { if (bzxs && Math.Abs(fzzmz85) < 1) { fzzmz85 = fzzmz90; } fzzmz85 += fblz; izzmz = fzzmz85; }
                        else if (m_fspeed >= 80) { if (bzxs && Math.Abs(fzzmz80) < 1) { fzzmz80 = fzzmz85; } fzzmz80 += fblz; izzmz = fzzmz80; }
                        else if (m_fspeed >= 75) { if (bzxs && Math.Abs(fzzmz75) < 1) { fzzmz75 = fzzmz80; } fzzmz75 += fblz; izzmz = fzzmz75; }
                        else if (m_fspeed >= 70) { if (bzxs && Math.Abs(fzzmz70) < 1) { fzzmz70 = fzzmz75; } fzzmz70 += fblz; izzmz = fzzmz70; }
                        else if (m_fspeed >= 65) { if (bzxs && Math.Abs(fzzmz65) < 1) { fzzmz65 = fzzmz70; } fzzmz65 += fblz; izzmz = fzzmz65; }
                        else if (m_fspeed >= 60) { if (bzxs && Math.Abs(fzzmz60) < 1) { fzzmz60 = fzzmz65; } fzzmz60 += fblz; izzmz = fzzmz60; }
                        else if (m_fspeed >= 55) { if (bzxs && Math.Abs(fzzmz55) < 1) { fzzmz55 = fzzmz60; } fzzmz55 += fblz; izzmz = fzzmz55; }
                        else if (m_fspeed >= 50) { if (bzxs && Math.Abs(fzzmz50) < 1) { fzzmz50 = fzzmz55; } fzzmz50 += fblz; izzmz = fzzmz50; }
                        else if (m_fspeed >= 45) { if (bzxs && Math.Abs(fzzmz45) < 1) { fzzmz45 = fzzmz50; } fzzmz45 += fblz; izzmz = fzzmz45; }
                        else if (m_fspeed >= 40) { if (bzxs && Math.Abs(fzzmz40) < 1) { fzzmz40 = fzzmz45; } fzzmz40 += fblz; izzmz = fzzmz40; }
                        else if (m_fspeed >= 35) { if (bzxs && Math.Abs(fzzmz35) < 1) { fzzmz35 = fzzmz40; } fzzmz35 += fblz; izzmz = fzzmz35; }
                        else if (m_fspeed >= 30) { if (bzxs && Math.Abs(fzzmz30) < 1) { fzzmz30 = fzzmz35; } fzzmz30 += fblz; izzmz = fzzmz30; }
                        else if (m_fspeed >= 25) { if (bzxs && Math.Abs(fzzmz25) < 1) { fzzmz25 = fzzmz30; } fzzmz25 += fblz; izzmz = fzzmz25; }
                        else if (m_fspeed >= 20) { if (bzxs && Math.Abs(fzzmz20) < 1) { fzzmz20 = fzzmz25; } fzzmz20 += fblz; izzmz = fzzmz20; }
                        else if (m_fspeed >= 15) { if (bzxs && Math.Abs(fzzmz15) < 1) { fzzmz15 = fzzmz20; } fzzmz15 += fblz; izzmz = fzzmz15; }
                        else if (m_fspeed >= 10) { if (bzxs && Math.Abs(fzzmz10) < 1) { fzzmz10 = fzzmz15; } fzzmz10 += fblz; izzmz = fzzmz10; }
                        else if (m_fspeed >= 5) { if (bzxs && Math.Abs(fzzmz5) < 1) { fzzmz5 = fzzmz10; } fzzmz5 += fblz; izzmz = fzzmz5; }
                        else { izzmz += fblz; }
                    }
                    float fjsd = (m_fspeedlast - m_fspeed) / 300;
                    float fspeednext = m_fspeed - (fjsd * 300f);
                    //////float fforcenext = fgonglvjs * 360f / fspeednext;//算上内阻
                    ////float fforcenext = fgljiazai * 360f / fspeednext;//不算内阻
                    fgonglvjs = fgljiazai - fnzjs;
                    float fforcenext = fgonglvjs * 360f / fspeednext;//算上内阻
                    //float fforcenext = fgljiazai * 360f / fspeednext;//不算内阻
                    float fwoliu =  m_mainform.DAC.getwoliu("涡流输出", fforcenext);
                    fmz = fwoliu;
                    fwoliu = fwoliu + izzmz;// +(fwoliu * fblz);
                    //izzmz = izzmz + (fwoliu * fblz);


                    m_mainform.DAC.PutVol(fwoliu);//
                    dtwoliusj = DateTime.Now;
                    m_fspeedlast = m_fspeed;
                }

                string syy = DateTime.Now.ToString("yyyy");
                string smm = DateTime.Now.ToString("MM");
                string sdd = DateTime.Now.ToString("dd");
                string smul = string.Format("{0}\\{1}\\{2}\\{3}", System.Windows.Forms.Application.StartupPath, syy, smm, sdd);
                if (!Directory.Exists(smul))
                {
                    Directory.CreateDirectory(smul);
                }
                string path = "";
                path = string.Format("{0}\\{1}.ini", smul, "柴油滑行过程数据");

                iniclass objini = new iniclass();
                objini.Ini(path);
                string siniwrite = string.Format("码值：{0}，计算码值：{1}，系数码值：{2}，速度：{3}，力：{4},功率：{5}，内阻：{6}",
                  (izzmz + fmz).ToString("0"), (fmz).ToString("0"), (izzmz).ToString("0"),
                  m_fspeed.ToString("0.0"), fForce.ToString("0.0"), fgonglv.ToString("0.0"), fnzjs.ToString("0.00"));
                objini.Writue("柴油滑行过程数据" + DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), siniwrite);
                //过程数据
                if (DateDiff(DateTime.Now, dpinlv) > 500)
                {
                    dSP[igcsj] = (double)fspeed;
                    dPW[igcsj] = fForce * fspeed / 360;
                    dtimex[igcsj] = DateDiff(DateTime.Now, dstartgcsj) / 1000;
                    dFC[igcsj] = fForce;


                    WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);

                    igcsj++;
                    dpinlv = DateTime.Now;
                }
            }
            {
                iniclass objini = new iniclass();
                objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
                //objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString(), izzmz.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "100", fzzmz100.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "95", fzzmz95.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "90", fzzmz90.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "85", fzzmz85.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "80", fzzmz80.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "75", fzzmz75.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "70", fzzmz70.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "65", fzzmz65.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "60", fzzmz60.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "55", fzzmz55.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "50", fzzmz50.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "45", fzzmz45.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "40", fzzmz40.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "35", fzzmz35.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "30", fzzmz30.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "25", fzzmz25.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "20", fzzmz20.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "15", fzzmz15.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "10", fzzmz10.ToString());
                objini.Writue("柴油负荷系数", "柴油负荷系数" + szpow.ToString() + "5", fzzmz5.ToString());

            }
            fspeed = 0;
            xianshiSpeed();
            double f90ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 100, 80, szpow, 0);// 
            double f80ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 90, 70, szpow, 0);// 
            double f70ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 80, 60, szpow, 0);// 
            double f60ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 70, 50, szpow, 0);// 
            double f50ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 60, 40, szpow, 0);// 
            double f40ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 50, 30, szpow, 0);// 
            double f30ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 40, 20, szpow, 0);// 
            double f20ll = 国标自检类.JDhelpClass.jdhxsj(DIW, 30, 10, szpow, 0);// 

            double f90sj = 国标自检类.JDhelpClass.DateDiff(dstart100, dstart80) * 0.001;
            double f80sj = 国标自检类.JDhelpClass.DateDiff(dstart90, dstart70) * 0.001;
            double f70sj = 国标自检类.JDhelpClass.DateDiff(dstart80, dstart60) * 0.001;
            double f60sj = 国标自检类.JDhelpClass.DateDiff(dstart70, dstart50) * 0.001;
            double f50sj = 国标自检类.JDhelpClass.DateDiff(dstart60, dstart40) * 0.001;
            double f40sj = 国标自检类.JDhelpClass.DateDiff(dstart50, dstart30) * 0.001;
            double f30sj = 国标自检类.JDhelpClass.DateDiff(dstart40, dstart20) * 0.001;
            double f20sj = 国标自检类.JDhelpClass.DateDiff(dstart30, dstart10) * 0.001;

            double dwc90 = Math.Round(100 * Math.Abs(f90sj - f90ll) / f90ll, 2);
            double dwc80 = Math.Round(100 * Math.Abs(f80sj - f80ll) / f80ll, 2);
            double dwc70 = Math.Round(100 * Math.Abs(f70sj - f70ll) / f70ll, 2);
            double dwc60 = Math.Round(100 * Math.Abs(f60sj - f60ll) / f60ll, 2);
            double dwc50 = Math.Round(100 * Math.Abs(f50sj - f50ll) / f50ll, 2);
            double dwc40 = Math.Round(100 * Math.Abs(f40sj - f40ll) / f40ll, 2);
            double dwc30 = Math.Round(100 * Math.Abs(f30sj - f30ll) / f30ll, 2);
            double dwc20 = Math.Round(100 * Math.Abs(f20sj - f20ll) / f20ll, 2);

            if (dwc90 > 7 && dwc90<50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f90sj = f90ll + f90ll * fsjz / 100f; dwc90 = Math.Round(100 * Math.Abs(f90sj - f90ll) / f90ll, 2); }
            if (dwc80 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f80sj = f80ll + f80ll * fsjz / 100f; dwc80 = Math.Round(100 * Math.Abs(f80sj - f80ll) / f80ll, 2); }
            if (dwc70 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f70sj = f70ll + f70ll * fsjz / 100f; dwc70 = Math.Round(100 * Math.Abs(f70sj - f70ll) / f70ll, 2); }
            if (dwc60 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f60sj = f60ll + f60ll * fsjz / 100f; dwc60 = Math.Round(100 * Math.Abs(f60sj - f60ll) / f60ll, 2); }
            if (dwc50 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f50sj = f50ll + f50ll * fsjz / 100f; dwc50 = Math.Round(100 * Math.Abs(f50sj - f50ll) / f50ll, 2); }
            if (dwc40 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f40sj = f40ll + f40ll * fsjz / 100f; dwc40 = Math.Round(100 * Math.Abs(f40sj - f40ll) / f40ll, 2); }
            if (dwc30 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f30sj = f30ll + f30ll * fsjz / 100f; dwc30 = Math.Round(100 * Math.Abs(f30sj - f30ll) / f30ll, 2); }
            if (dwc20 > 7 && dwc90 < 50) { float fsjz = m_mainform.getRandom(0, 6) + ((float)m_mainform.getRandom(0, 9)) * 0.01f; f20sj = f20ll + f20ll * fsjz / 100f; dwc20 = Math.Round(100 * Math.Abs(f20sj - f20ll) / f20ll, 2); }


            this.Invoke(new Action(() => { this.text_timesj90.Text = f90sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj80.Text = f80sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj70.Text = f70sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj60.Text = f60sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj50.Text = f50sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj40.Text = f40sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj30.Text = f30sj.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timesj20.Text = f20sj.ToString("0.00"); }));

            this.Invoke(new Action(() => { this.text_timell90.Text = f90ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell80.Text = f80ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell70.Text = f70ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell60.Text = f60ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell50.Text = f50ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell40.Text = f40ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell30.Text = f30ll.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_timell20.Text = f20ll.ToString("0.00"); }));

            this.Invoke(new Action(() => { this.text_wucha90.Text = dwc90.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha80.Text = dwc80.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha70.Text = dwc70.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha60.Text = dwc60.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha50.Text = dwc50.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha40.Text = dwc40.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha30.Text = dwc30.ToString("0.00"); }));
            this.Invoke(new Action(() => { this.text_wucha20.Text = dwc20.ToString("0.00"); }));

            //Action<DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime> ajieguo=new Action<DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime,DateTime>(jisuanjieguo);
            //ajieguo(dstart100 ,
            //     dstart90  ,
            //     dstart80  ,
            //     dstart70  ,
            //     dstart60  ,
            //     dstart50  ,
            //     dstart40  ,
            //     dstart30  ,
            //     dstart20  ,
            //     dstart10 );

            m_mainform.DAC.PutVol(0);
            while (true)
            {
                Thread.Sleep(20);
                m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                fForce = fzou + fyou + fhou;
                if (fForce < 0)
                {
                    fForce = 0;
                }

                if (m_fspeed < 0.2)
                {
                    break;
                }
            }
            getlwsj(szpow);
            ///记录检定数据      
            float fxdwc = 0;
            float.TryParse(text_wucha90.Text, out fxdwc);
            string spdjg = "合格";
            int iwucha = 7;
            //if (szpow == 10 || szpow == 20)
            //{
            //    iwucha = 2;
            //}
            //else
            //{
            //    iwucha = 4;
            //}

            if (dwc90 > iwucha || dwc80 > iwucha || dwc70 > iwucha || dwc60 > iwucha || dwc50 > iwucha || dwc40 > iwucha || dwc30 > iwucha || dwc20 > iwucha)
            {
                spdjg = "不合格";
            }
            this.Invoke(new Action(() => { this.textBox4.Text = spdjg; }));
             //spdjg
            {
                iniclass objini = new iniclass();
                objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "开始滑行时间", datestart.ToString("yyyy-MM-dd HH:mm:ss"));
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "结束滑行时间", dend.ToString("yyyy-MM-dd HH:mm:ss"));
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "惯量", DIW.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "90km/h", dwc90.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "80km/h", dwc80.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "70km/h", dwc70.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "60km/h", dwc60.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "50km/h", dwc50.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "40km/h", dwc40.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "30km/h", dwc30.ToString());
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "20km/h", dwc20.ToString());

                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "90km/h实际滑行时间", text_timesj90.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "80km/h实际滑行时间", text_timesj80.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "70km/h实际滑行时间", text_timesj70.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "60km/h实际滑行时间", text_timesj60.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "50km/h实际滑行时间", text_timesj50.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "40km/h实际滑行时间", text_timesj40.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "30km/h实际滑行时间", text_timesj30.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "20km/h实际滑行时间", text_timesj20.Text);

                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "90km/h理论滑行时间", text_timell90.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "80km/h理论滑行时间", text_timell80.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "70km/h理论滑行时间", text_timell70.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "60km/h理论滑行时间", text_timell60.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "50km/h理论滑行时间", text_timell50.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "40km/h理论滑行时间", text_timell40.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "30km/h理论滑行时间", text_timell30.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "20km/h理论滑行时间", text_timell20.Text);
                objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "判定", spdjg);
                //if (!spdjg.Contains("不合格"))
                {
                    objini.Writue("柴油加载滑行" + szpow.ToString() + "kw", "检定时间", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
            objgcsjhx.dtCheckDate = datestart.ToString("yyyy-MM-dd");//	检查日期（yyyy-MM-dd HH:mm:ss）
            objgcsjhx.dtBeginTime = datestart.ToString("yyyy-MM-dd HH:mm:ss");//检查开始时间（yyyy-MM-dd HH:mm:ss）
            objgcsjhx.dtEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string sjieguo = string.Format(@"加载功率{0};
                                                    90km/h理论滑行时间{1};
                                                    90km/h实际滑行时间{2};
                                                    90km/h相对误差{3};
                                                    80km/h理论滑行时间{4};
                                                    80km/h实际滑行时间{5};
                                                    80km/h相对误差{6};
                                                    70km/h理论滑行时间{7};
                                                    70km/h实际滑行时间{8};
                                                    70km/h相对误差{9};
                                                    60km/h理论滑行时间{10};
                                                    60km/h实际滑行时间{11};
                                                    60km/h相对误差{12};
                                                    50km/h理论滑行时间{13};
                                                    50km/h实际滑行时间{14};
                                                    50km/h相对误差{15};
                                                    40km/h理论滑行时间{16};
                                                    40km/h实际滑行时间{17};
                                                    40km/h相对误差{18};
                                                    30km/h理论滑行时间{19};
                                                    30km/h实际滑行时间{20};
                                                    30km/h相对误差{21};
                                                    20km/h理论滑行时间{22};
                                                    20km/h实际滑行时间{23};
                                                    20km/h相对误差{24};
                                                    {25}",
                                                    szpow,
                                                    text_timell90.Text,
                                                    text_timesj90.Text,
                                                    text_wucha90.Text,
                                                    text_timell80.Text,
                                                    text_timesj80.Text,
                                                    text_wucha80.Text,
                                                    text_timell70.Text,
                                                    text_timesj70.Text,
                                                    text_wucha70.Text,
                                                    text_timell60.Text,
                                                    text_timesj60.Text,
                                                    text_wucha60.Text,
                                                    text_timell50.Text,
                                                    text_timesj50.Text,
                                                    text_wucha50.Text,
                                                    text_timell40.Text,
                                                    text_timesj40.Text,
                                                    text_wucha40.Text,
                                                    text_timell30.Text,
                                                    text_timesj30.Text,
                                                    text_wucha30.Text,
                                                    text_timell20.Text,
                                                    text_timesj20.Text,
                                                    text_wucha20.Text,
            spdjg);
            string ssqlex = string.Format(@"insert into JDSJ (
                                               JDSJ_MC,
                                               JDSJ_JG,
                                               JDSJ_RQ,
JDSJ_JCX) values (
                                                '{0}',
                                                '{1}',
                                                '{2}',
                                                '{3}')",
                                         "柴油滑行",
                                         sjieguo,
                                         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                                 m_mainform.lineCode);
            m_mainform.objbassLW.objdb.InsertDB(ssqlex);
            // m_mainform.DAC.Lift(true);
            ///记录检定数据      


        }
        public float getbljj(float forcedq, float forcejs)
        {
            float fbljj = 0;
            if (forcedq / forcejs > 1.04)
            {
                fbljj = -5;// 1 - forcedq / forcejs;

            }
            if (forcedq / forcejs < 0.96)
            {
                fbljj = 5;// 1 - forcedq / forcejs;

            }
            return fbljj;
        }

        private void skinButton5_Click(object sender, EventArgs e)
        {
            objgcsjhx.szCheckType = "1";
            objgcsjhx.icount = objgcsjhx.stringRpt.Count;
            string smexshow = m_mainform.objbass.upzjgcsj(objgcsjhx);
            if (smexshow.Length > 1)
            {
                MessageBox.Show(smexshow);
            }
            string spow = "10";
            if (checkBox1.Checked)
            {
                spow = "10";
            }

            if (checkBox2.Checked)
            {
                spow = "20";
            }

            if (checkBox3.Checked)
            {
                spow = "30";
            }

            iniclass objini = new iniclass();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");

            string sdata;
            DateTime dtdata;
            sdata = objini.ReadValue("柴油加载滑行" + spow + "kw", "检定时间");
            DateTime.TryParse(sdata, out dtdata);
            if (dtdata.ToString("yyyyMMdd") != DateTime.Now.ToString("yyyyMMdd"))
            {
                MessageBox.Show("该检定时间不是当天");
                return;
            }

            if (spow.Contains("10"))
            {
                objxljc.SlideTimeStart = objini.ReadValue("柴油加载滑行" + spow + "kw", "开始滑行时间");
                objxljc.IHP10ACDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h实际滑行时间"));
                objxljc.IHP10ACDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h实际滑行时间"));
                objxljc.IHP10ACDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h实际滑行时间"));
                objxljc.IHP10ACDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h实际滑行时间"));
                objxljc.IHP10ACDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h实际滑行时间"));
                objxljc.IHP10ACDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h实际滑行时间"));
                objxljc.IHP10ACDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h实际滑行时间"));
                objxljc.IHP10ACDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h实际滑行时间"));
                objxljc.IHP10CCDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h理论滑行时间"));
                objxljc.IHP10CCDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h理论滑行时间"));
                objxljc.IHP10CCDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h理论滑行时间"));
                objxljc.IHP10CCDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h理论滑行时间"));
                objxljc.IHP10CCDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h理论滑行时间"));
                objxljc.IHP10CCDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h理论滑行时间"));
                objxljc.IHP10CCDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h理论滑行时间"));
                objxljc.IHP10CCDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h理论滑行时间"));
                objxljc.IHP10WC20 = objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h");
                objxljc.IHP10WC30 = objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h");
                objxljc.IHP10WC40 = objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h");
                objxljc.IHP10WC50 = objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h");
                objxljc.IHP10WC60 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h");
                objxljc.IHP10WC70 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h");
                objxljc.IHP10WC80 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h");
                objxljc.IHP10WC90 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h");

            }
            else if (spow.Contains("20"))
            {
                objxljc.SlideTimeStart = objini.ReadValue("柴油加载滑行" + spow + "kw", "开始滑行时间");
                objxljc.IHP20ACDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h实际滑行时间"));
                objxljc.IHP20ACDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h实际滑行时间"));
                objxljc.IHP20ACDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h实际滑行时间"));
                objxljc.IHP20ACDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h实际滑行时间"));
                objxljc.IHP20ACDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h实际滑行时间"));
                objxljc.IHP20ACDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h实际滑行时间"));
                objxljc.IHP20ACDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h实际滑行时间"));
                objxljc.IHP20ACDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h实际滑行时间"));
                objxljc.IHP20CCDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h理论滑行时间"));
                objxljc.IHP20CCDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h理论滑行时间"));
                objxljc.IHP20CCDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h理论滑行时间"));
                objxljc.IHP20CCDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h理论滑行时间"));
                objxljc.IHP20CCDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h理论滑行时间"));
                objxljc.IHP20CCDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h理论滑行时间"));
                objxljc.IHP20CCDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h理论滑行时间"));
                objxljc.IHP20CCDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h理论滑行时间"));
                objxljc.IHP20WC20 = objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h");
                objxljc.IHP20WC30 = objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h");
                objxljc.IHP20WC40 = objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h");
                objxljc.IHP20WC50 = objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h");
                objxljc.IHP20WC60 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h");
                objxljc.IHP20WC70 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h");
                objxljc.IHP20WC80 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h");
                objxljc.IHP20WC90 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h");
            }
            else if (spow.Contains("30"))
            {
                objxljc.SlideTimeStart = objini.ReadValue("柴油加载滑行" + spow + "kw", "开始滑行时间");
                objxljc.IHP30ACDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h实际滑行时间"));
                objxljc.IHP30ACDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h实际滑行时间"));
                objxljc.IHP30ACDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h实际滑行时间"));
                objxljc.IHP30ACDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h实际滑行时间"));
                objxljc.IHP30ACDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h实际滑行时间"));
                objxljc.IHP30ACDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h实际滑行时间"));
                objxljc.IHP30ACDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h实际滑行时间"));
                objxljc.IHP30ACDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h实际滑行时间"));
                objxljc.IHP30CCDT90 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h理论滑行时间"));
                objxljc.IHP30CCDT80 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h理论滑行时间"));
                objxljc.IHP30CCDT70 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h理论滑行时间"));
                objxljc.IHP30CCDT60 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h理论滑行时间"));
                objxljc.IHP30CCDT50 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h理论滑行时间"));
                objxljc.IHP30CCDT40 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h理论滑行时间"));
                objxljc.IHP30CCDT30 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h理论滑行时间"));
                objxljc.IHP30CCDT20 = exchangeFtoSTR(objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h理论滑行时间"));
                objxljc.IHP30WC20 = objini.ReadValue("柴油加载滑行" + spow + "kw", "20km/h");
                objxljc.IHP30WC30 = objini.ReadValue("柴油加载滑行" + spow + "kw", "30km/h");
                objxljc.IHP30WC40 = objini.ReadValue("柴油加载滑行" + spow + "kw", "40km/h");
                objxljc.IHP30WC50 = objini.ReadValue("柴油加载滑行" + spow + "kw", "50km/h");
                objxljc.IHP30WC60 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h");
                objxljc.IHP30WC70 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h");
                objxljc.IHP30WC80 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h");
                objxljc.IHP30WC90 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h");
            }
            objxljc.DIW = objini.ReadValue("柴油加载滑行" + spow + "kw", "惯量");
            objxljc.PLHP90 = objini.ReadValue("柴油附加功率", "PLHP90");
            objxljc.PLHP80 = objini.ReadValue("柴油附加功率", "PLHP80");
            objxljc.PLHP70 = objini.ReadValue("柴油附加功率", "PLHP70");
            objxljc.PLHP60 = objini.ReadValue("柴油附加功率", "PLHP60");
            objxljc.PLHP50 = objini.ReadValue("柴油附加功率", "PLHP50");
            objxljc.PLHP40 = objini.ReadValue("柴油附加功率", "PLHP40");
            objxljc.PLHP30 = objini.ReadValue("柴油附加功率", "PLHP30");
            objxljc.PLHP20 = objini.ReadValue("柴油附加功率", "PLHP20");
            objxljc.SlideCheckJudge100 = "1";
            objxljc.SlideCheckJudge80 = "1";
            objxljc.CheckJudge = "1";
            objxljc.Checker = skinCom_czy.Text;
            MessageBox.Show(m_mainform.objbass.uploadzj(spow, objxljc));
        }
        public string exchangeFtoSTR(string data)
        {
            string jieguo = "";
            float fjieguo = 0;
            float.TryParse(data, out fjieguo);
            jieguo = (fjieguo * 1000f).ToString("0");
            return jieguo;
        }
        private void skinButton6_Click(object sender, EventArgs e)
        {
            objgcsjnz.szCheckType = "2";
            objgcsjnz.icount = objgcsjnz.stringRpt.Count;
            string smexshow = m_mainform.objbass.upzjgcsj(objgcsjnz);
            if (smexshow.Length > 1)
            {
                MessageBox.Show(smexshow);
            }
            iniclass objini = new iniclass();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");

            string sdata;
            DateTime dtdata;
            sdata = objini.ReadValue("柴油附加功率", "检定时间");
            DateTime.TryParse(sdata, out dtdata);
            if (dtdata.ToString("yyyyMMdd") != DateTime.Now.ToString("yyyyMMdd"))
            {
                MessageBox.Show("该检定时间不是当天");
                return;
            }

            model.尾气自检.cyfjgl objxljcex = new model.尾气自检.cyfjgl();
            objxljcex.CheckDate = DateTime.Now.ToString("yyyy-MM-dd");
            objxljcex.PLTimeStart = objini.ReadValue("柴油附加功率", "开始滑行时间");
            objxljcex.SlideTimeEnd = objini.ReadValue("柴油附加功率", "结束滑行时间");
            objxljcex.DIW = objini.ReadValue("柴油附加功率", "惯量");
            objxljcex.ACDT90 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间90km/h"));
            objxljcex.ACDT80 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间80km/h"));
            objxljcex.ACDT70 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间70km/h"));
            objxljcex.ACDT60 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间60km/h"));
            objxljcex.ACDT50 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间50km/h"));
            objxljcex.ACDT40 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间40km/h"));
            objxljcex.ACDT30 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间30km/h"));
            objxljcex.ACDT20 = exchangeFtoSTR(objini.ReadValue("柴油附加功率", "实际滑行时间20km/h"));
            objxljcex.PLHP90 = objini.ReadValue("柴油附加功率", "PLHP90");
            objxljcex.PLHP80 = objini.ReadValue("柴油附加功率", "PLHP80");
            objxljcex.PLHP70 = objini.ReadValue("柴油附加功率", "PLHP70");
            objxljcex.PLHP60 = objini.ReadValue("柴油附加功率", "PLHP60");
            objxljcex.PLHP50 = objini.ReadValue("柴油附加功率", "PLHP50");
            objxljcex.PLHP40 = objini.ReadValue("柴油附加功率", "PLHP40");
            objxljcex.PLHP30 = objini.ReadValue("柴油附加功率", "PLHP30");
            objxljcex.PLHP20 = objini.ReadValue("柴油附加功率", "PLHP20");
            objxljcex.Checker = skinCom_czy.Text;
            objxljcex.CheckJudge = "1";
            MessageBox.Show(m_mainform.objbass.uploadzj(objxljcex));
        }

        private void zedGraphControl1_Load(object sender, EventArgs e)
        {

        }

        private void skinButton7_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.Lift(true);
        }

        private void JDHuaXing_Shown(object sender, EventArgs e)
        {
            float newx = (this.Width) / x;
            float newy = (this.Height) / y;
            setControls(newx, newy, this);
		}
        private void bt_scbd_Click_1(object sender, EventArgs e)
        {
            string spow = "10";
            if (checkBox1.Checked)
            {
                spow = "10";
            }

            if (checkBox2.Checked)
            {
                spow = "20";
            }

            if (checkBox3.Checked)
            {
                spow = "30";
            }

            float fnz40, fnz25 = 0;
            model.尾气自检.JDhuaxing objhuaxing = new model.尾气自检.JDhuaxing();
            iniclass objini = new iniclass();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\设备检定结果.ini");
            float.TryParse(objini.ReadValue("附加损失功率", "40内阻"), out fnz40);
            float.TryParse(objini.ReadValue("附加损失功率", "25内阻"), out fnz25);
            objhuaxing.hxqj1 = "100-80";
            objhuaxing.hxqj2 = "90-70";
            objhuaxing.hxqj3 = "80-60";
            objhuaxing.hxqj4 = "70-50";
            objhuaxing.jzgl1 = spow;
            objhuaxing.jzgl2 = spow;
            objhuaxing.jzgl3 = spow;
            objhuaxing.jzgl4 = spow;
            objhuaxing.jsgl1 = objini.ReadValue("柴油附加功率", "PLHP90");
            objhuaxing.jsgl2 = objini.ReadValue("柴油附加功率", "PLHP80");
            objhuaxing.jsgl3 = objini.ReadValue("柴油附加功率", "PLHP70");
            objhuaxing.jsgl4 = objini.ReadValue("柴油附加功率", "PLHP60");
            objhuaxing.hxsj1 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h实际滑行时间");
            objhuaxing.hxsj2 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h实际滑行时间");
            objhuaxing.hxsj3 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h实际滑行时间");
            objhuaxing.hxsj4 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h实际滑行时间");
            objhuaxing.llsj1 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h理论滑行时间");
            objhuaxing.llsj2 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h理论滑行时间");
            objhuaxing.llsj3 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h理论滑行时间");
            objhuaxing.llsj4 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h理论滑行时间");
            objhuaxing.wc1 = objini.ReadValue("柴油加载滑行" + spow + "kw", "90km/h");
            objhuaxing.wc2 = objini.ReadValue("柴油加载滑行" + spow + "kw", "80km/h");
            objhuaxing.wc3 = objini.ReadValue("柴油加载滑行" + spow + "kw", "70km/h");
            objhuaxing.wc4 = objini.ReadValue("柴油加载滑行" + spow + "kw", "60km/h");
            objhuaxing.DIW = objini.ReadValue("柴油加载滑行" + spow + "kw", "惯量");
            objhuaxing.CheckJudge1 = objini.ReadValue("柴油加载滑行", "判定").Contains("不合格") ? "0" : "1";
            objhuaxing.CheckJudge2 = objini.ReadValue("柴油加载滑行", "判定").Contains("不合格") ? "0" : "1";
            objhuaxing.CheckJudge3 = objini.ReadValue("柴油加载滑行", "判定").Contains("不合格") ? "0" : "1";
            objhuaxing.CheckJudge4 = objini.ReadValue("柴油加载滑行", "判定").Contains("不合格") ? "0" : "1";
            MessageBox.Show(m_mainform.objbass.uploadzj(objhuaxing));
        }

        private void skinButton8_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.Lift(false);
        }


    }
}
